Jump to content

Archived

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

fixxxer

multiple submit boxes on same form

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

Share this post


Link to post
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]

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.