Jump to content

Having 2 if POST Submit in 1 file.


Bradley99

Recommended Posts

Hi, I'm having trouble with having 2

if ($_POST['Submit']){

forms in 1 file.

 

I have two forms(tables) in the file, Both of which update the same table but in different ways. So for example. Form 1 INSERTS into the first 9 columns dependant on what is picked from the form then the rest of the columns are set to default.

And form 2 INSERTS a new row but only inserts into the last 4 columns, again dependant on what is picked from the form, with the other columns set to default.

 

But what is happening when I hit 'Submit' on EITHER of the forms, It is creating 2 new rows, one with the info from the form I submitted, and 1 that is all defaults values from the second

if ($_POST['Submit']){

form.

 

Here's my code.

if ($_POST['Submit']){
$viewevent = $_POST['event_id'];
$fight_id = $_POST['fight_id'];
$fighter_id = $_POST['fighter_id'];
$method = $_POST['method'];
$round = $_POST['round'];
$bonus = $_POST['bonus'];
$fotn_id = $_POST['fotn_id'];
$sotn_id = $_POST['sotn_id'];
$kootn_id = $_POST['kootn_id'];

{

mysql_query("INSERT INTO betting (`bet_id` , `event_id` , `fight_id` , `user_id` , `fighter_id`, `method`, `round`, `bonus`)
VALUES ('', '$fetch->id', '$fight_id', '$user->id', '$fighter_id', '$method','$round','$bonus')") or die (mysql_error());
echo "You picked $fighter_id, Good Luck!"; 
}
{
mysql_query("INSERT INTO betting (`bet_id` , `event_id` , `fight_id` , `user_id` , `fighter_id`, `method`, `round`, `bonus`, `fotn_id`, `sotn_id`, `kootn_id`)
VALUES ('', '$fetch->id', '0', '$user->id', '0', '0', '0', '0', '$fotn_id', '$sotn_id', '$kootn_id' )") or die (mysql_error());
echo "You picked $fighter_id, Good Luck!";

}}
?>

 

I did try having the second forms PHP AFTER the first forms HTML, but that produces the same result.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/264908-having-2-if-post-submit-in-1-file/
Share on other sites

Thanks, I did try that but used Submit & submit (capital change) but didn't work, Submit1 & Submit2 does. Cheers.

 

Would you know by anychance why when I submit the second form, the page reloads back to where it was, but if i submit the second form i get just an echo?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.