Jump to content


Photo

multiple submit boxes on same form


  • Please log in to reply
2 replies to this topic

#1 fixxxer

fixxxer
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 31 May 2006 - 03:48 PM

On a form i have i have two submit boxes which i wanted to use to redirect a user depending on wich box was selected from the form.

heres the form :



<form action="../upload_cover_image.php" method="post" enctype="multipart/form-data" name="upload_photo">
<p>
<input name="cover_id" type="hidden" id="cover_id" value="<?php echo $row_rsCoverpresent['cover_id']; ?>" />
<input type="hidden" name="image_caption" value="Cover Image for <?php echo $row_rsGame['game_name']; ?> on <?php echo $row_rsGameformats['gameformat_name']; ?>" />
<br />
<input name="cover_user_id" type="hidden" id="cover_user_id" value="<?php echo $_SESSION['user_id']?>" />
<input name="image_filename" type="file" id="image_filename" />
</p>
<p>
<input name="action" type="submit" value="Submit and Add Screenshots" />
<br />
<br />
<input name="action" type="submit" value="Submit and Go To Review" />

</p>
</form>

the highlighted section is the two submit boxes, when theyre pass over i execute a script to update the data base and then depending on which one was pressed redirect the user. ive checked 'action' and its also set correctly depending on which button was pressed but the if statement i use always executes the first part of the if statement no matter which one was selected. heres the if statement:

if ($_POST['action'] = 'Submit and Go To Review') {


redirect('user_add/addscreenshots.php');

} else if ($_POST['action'] = 'Submit and Add Screenshots') {


redirect('user_add/reviewgameentry.php');

}

but it always selects the first option even if action is set to 'submit and add screenshots' can anyone explain what ive done wrong

thanks



#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 31 May 2006 - 05:31 PM

you need to use the == in the if statement instead of the =
if ($_POST['action'] == 'Submit and Go To Review') {


redirect('user_add/addscreenshots.php');

} else if ($_POST['action'] == 'Submit and Add Screenshots') {


redirect('user_add/reviewgameentry.php');

}

NoGray.com


#3 fixxxer

fixxxer
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 31 May 2006 - 09:33 PM

[!--quoteo(post=378779:date=May 31 2006, 12:31 PM:name=nogray)--][div class=\'quotetop\']QUOTE(nogray @ May 31 2006, 12:31 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
you need to use the == in the if statement instead of the =
if ($_POST['action'] == 'Submit and Go To Review') {
redirect('user_add/addscreenshots.php');

} else if ($_POST['action'] == 'Submit and Add Screenshots') {
redirect('user_add/reviewgameentry.php');

}
[/quote]

hey thanks for that, spot on.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users