Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.