Jump to content

multiple submit boxes on same form


fixxxer

Recommended Posts

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>
[b]<input name="action" type="submit" value="Submit and Add Screenshots" />
<br />
<br />
<input name="action" type="submit" value="Submit and Go To Review" />[/b]
</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

Link to comment
Share on other sites

you need to use the == in the if statement instead of the =
[code]
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');

}
[/code]
Link to comment
Share on other sites

[!--quoteo(post=378779:date=May 31 2006, 12:31 PM:name=nogray)--][div class=\'quotetop\']QUOTE(nogray @ May 31 2006, 12:31 PM) [snapback]378779[/snapback][/div][div class=\'quotemain\'][!--quotec--]
you need to use the == in the if statement instead of the =
[code]
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');

}
[/code]
[/quote]

hey thanks for that, spot on.
Link to comment
Share on other sites

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.