/    Sign up×
Community /Pin to ProfileBookmark

Multiple Form Actions

Hi,

I’m trying to make one form, with one button, do 2 things.

What it is, is send the details entered to the MySQL Database, and also process the form as well, and display what was entered etc on the thanks.php page.

Can get them both working individually, but not together

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJan 17.2005 — hi,

isnt writing to the MySQL database a process from the form information?

if yes, then what do you mean by "process the form", do you mean things like verify the entry?

maybe you could post ur code
Copy linkTweet thisAlerts:
@kevinmcqueenauthorJan 17.2005 — <form name="form1" method="POST" action="<?php echo $editFormAction; ?>; ">

<--The Form Fields are Here (Removed)-->

<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
<br>
<input type="hidden" name="MM_insert" value="form1">
</form>


works fine...

<form name="form1" method="POST" action="thanks.php">

<--The Form Fields are Here (Removed)-->

<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
<br>
<input type="hidden" name="MM_insert" value="form1">
</form>

Works Fine.

But I want both the actions to inside one statement, so it does both.

On the thanks.php page I have

<?php

echo 'Thank you '; echo $name; echo ' for donating the following:<br><br>';

echo '<BR><BR>Amount: ';echo $_POST['Amount']; echo '<BR>';

echo '<BR><BR>Sponsor Type: ';echo $type; echo '<BR><BR>';

?>
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJan 17.2005 — what do you want ur users to input in the first lot of forms, and in the second? is it the same?

cant u ask all in a same form? and process from the same file?

u could write to the dB with the thanks.php file, and display the output at the same time.
Copy linkTweet thisAlerts:
@kevinmcqueenauthorJan 17.2005 — They are both the same form yes.

But just changed the action statement for demo purposes.

How do you write to the database, without having a submit button? using the thanks.php page. I'd imagine, it was all hidden fields of some sort?
Copy linkTweet thisAlerts:
@DaiWelshJan 17.2005 — If I understand it correctly, what you are trying to achieve in chronological order is

  • - Submit Form

  • - Write data to database

  • - Redirect to thank you page (with some data still availabel for display)


  • This seems to come up frequently with dreamweaver due to the way it does database inserts/updates. What you need to do is edit the 'form handling page' (the one pointed to by $editFormAction by the look of it) so that after inserting/updating/whatever the record it redirects to your thank you page and passes the required variables. For example something like

    header('Location: thankyou.php?name='.$name.'&Amount='.$Amount);

    but with as many fields tacked on as you need in the thank you page.

    Alternatively if you are writing all that info into the database anyway, just pass the id of the record to the thank you page and it can load the data from the database itself.

    Either way will work, but the latter is probably a bit more robust.

    HTH,

    Dai
    Copy linkTweet thisAlerts:
    @kevinmcqueenauthorJan 17.2005 — Thanks for that.

    That is what I have decided to do to, just take the info from database itself.

    Thanks
    ×

    Success!

    Help @kevinmcqueen spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...