fixxxer Posted May 31, 2006 Share Posted May 31, 2006 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 wrongthanks Quote Link to comment https://forums.phpfreaks.com/topic/10873-multiple-submit-boxes-on-same-form/ Share on other sites More sharing options...
nogray Posted May 31, 2006 Share Posted May 31, 2006 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 Link to comment https://forums.phpfreaks.com/topic/10873-multiple-submit-boxes-on-same-form/#findComment-40632 Share on other sites More sharing options...
fixxxer Posted May 31, 2006 Author Share Posted May 31, 2006 [!--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. Quote Link to comment https://forums.phpfreaks.com/topic/10873-multiple-submit-boxes-on-same-form/#findComment-40709 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.