dean012 Posted October 9, 2013 Share Posted October 9, 2013 <form action ="trip1.php" method="post"> <p><input type="checkbox" name="agree" /> Auckland</p> <form action ="trip.php" method="post"> <p><input type="checkbox" name="agree" /> North Shore</p> <p><input type="checkbox" name="agree" /> Waikato</p> <p><input type="checkbox" name="agree" /> Taranaki</p> <p><input type="checkbox" name="agree" /> Toupo</p> <p><input type="checkbox" name="agree" /> Wellington/p> <p><input type="checkbox" name="agree" /> Bay of Plenty</p> <p><input type="checkbox" name="agree" /> Manukau</p> <p><input type="submit" value="submit" /></p> </div> i put different action but when i hit submit it still bring me to the same page Quote Link to comment https://forums.phpfreaks.com/topic/282830-i-put-different-action-but-when-i-hit-submit-it-still-bring-me-to-the-same-page/ Share on other sites More sharing options...
winningdave Posted October 9, 2013 Share Posted October 9, 2013 You've got a form within form which you can't so. If you need two separate forms on a page you will need to close them properly then using JavaScript is the easiest way to submit different forms. <form action ="trip1.php" method="post" name="form1"> <p><input type="checkbox" name="agree" /> Auckland</p> </form> <form action ="trip.php" method="post" name="form2"> <p><input type="checkbox" name="agree" /> North Shore</p> <p><input type="checkbox" name="agree" /> Waikato</p> <p><input type="checkbox" name="agree" /> Taranaki</p> <p><input type="checkbox" name="agree" /> Toupo</p> <p><input type="checkbox" name="agree" /> Wellington/p> <p><input type="checkbox" name="agree" /> Bay of Plenty</p> <p><input type="checkbox" name="agree" /> Manukau</p> <p><input type="submit" value="submit" onclick="form2.submit();"/></p> </div> </form> Quote Link to comment https://forums.phpfreaks.com/topic/282830-i-put-different-action-but-when-i-hit-submit-it-still-bring-me-to-the-same-page/#findComment-1453228 Share on other sites More sharing options...
PravinS Posted October 9, 2013 Share Posted October 9, 2013 each form should have its own submit button and every form should have close tag Quote Link to comment https://forums.phpfreaks.com/topic/282830-i-put-different-action-but-when-i-hit-submit-it-still-bring-me-to-the-same-page/#findComment-1453229 Share on other sites More sharing options...
winningdave Posted October 9, 2013 Share Posted October 9, 2013 You will also need to look at what you're calling your checkboxes. Each name should be unique. You may have to also assign each one a value depending on how your using it Quote Link to comment https://forums.phpfreaks.com/topic/282830-i-put-different-action-but-when-i-hit-submit-it-still-bring-me-to-the-same-page/#findComment-1453231 Share on other sites More sharing options...
dean012 Posted October 9, 2013 Author Share Posted October 9, 2013 did not work Quote Link to comment https://forums.phpfreaks.com/topic/282830-i-put-different-action-but-when-i-hit-submit-it-still-bring-me-to-the-same-page/#findComment-1453232 Share on other sites More sharing options...
Ch0cu3r Posted October 9, 2013 Share Posted October 9, 2013 Cold you explain what you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/282830-i-put-different-action-but-when-i-hit-submit-it-still-bring-me-to-the-same-page/#findComment-1453234 Share on other sites More sharing options...
Barand Posted October 9, 2013 Share Posted October 9, 2013 (edited) Name all the checkboxes with name='agree[]' They are then posted as an array And, yes, without values they are useless Edited October 9, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/282830-i-put-different-action-but-when-i-hit-submit-it-still-bring-me-to-the-same-page/#findComment-1453288 Share on other sites More sharing options...
dean012 Posted October 12, 2013 Author Share Posted October 12, 2013 ok so i was tryng to make a multiple checkboxe that will tae me to different page with a single submit button Quote Link to comment https://forums.phpfreaks.com/topic/282830-i-put-different-action-but-when-i-hit-submit-it-still-bring-me-to-the-same-page/#findComment-1453632 Share on other sites More sharing options...
dean012 Posted October 12, 2013 Author Share Posted October 12, 2013 and so far i tried <form action ="taupo.php" method="post" name="form1"> <p><input type="checkbox" name='agree[]' /> Auckland</p> </form> <form action ="hamilton.php" method="post" name="form2"> <p><input type="checkbox" name='agree[]' /> North Shore</p> </form> <p><input type="checkbox" name='agree[]' /> Waikato</p> <p><input type="checkbox" name="agree[]" /> Taranaki</p> <p><input type="checkbox" name="agree[]" /> Taupo</p> <p><input type="checkbox" name="agree[]" /> Wellington/p> <p><input type="checkbox" name="agree[]" /> Bay of Plenty</p> <p><input type="checkbox" name="agree[]" /> Manukau</p> <p><input type="submit" value="submit" onclick="form2.submit();"/></p> </div> </form> Quote Link to comment https://forums.phpfreaks.com/topic/282830-i-put-different-action-but-when-i-hit-submit-it-still-bring-me-to-the-same-page/#findComment-1453637 Share on other sites More sharing options...
Ch0cu3r Posted October 12, 2013 Share Posted October 12, 2013 (edited) Not sure what you're wanting to do, but if you want the user to select multiple locations you'd setup the form like <form action ="location.php" method="post"> <p><input type="checkbox" name="locations[]" value="Auckland" /> Auckland</p> <p><input type="checkbox" name="locations[]" value="North Shore" /> North Shore</p> <p><input type="checkbox" name="locations[]" value="Waikato" /> Waikato</p> <p><input type="checkbox" name="locations[]" value="Taranaki" /> Taranaki</p> <p><input type="checkbox" name="locations[]" value="Taupo" /> Taupo</p> <p><input type="checkbox" name="locations[]" value="Wellington" /> Wellington/p> <p><input type="checkbox" name="locations[]" value="Bay of lenty" /> Bay of Plenty</p> <p><input type="checkbox" name="locations[]" value="Manukau" /> Manukau</p> <p><input type="submit" name="submit" value="submit" /></p> </form> The location goes in the value="" attribute for each checkbox. Then in location.php the $_POST['locations'] variable will contain an array of selected locations. Example code for location.php, for displaying the selected locations <?php if(isset($_POST['submit'])) { echo 'You have selected the following locations: '; echo '<ul><li>' . implode('</li><li>', $_POST['locations']) . '</li></ul>'; } ?> Edited October 12, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/282830-i-put-different-action-but-when-i-hit-submit-it-still-bring-me-to-the-same-page/#findComment-1453647 Share on other sites More sharing options...
Barand Posted October 12, 2013 Share Posted October 12, 2013 (edited) <form action ="taupo.php" method="post" name="form1"> <p><input type="checkbox" name='agree[]' /> Auckland</p> </form> <form action ="hamilton.php" method="post" name="form2"> <p><input type="checkbox" name='agree[]' /> North Shore</p> </form> <--- Your 2nd form ends here! <p><input type="checkbox" name='agree[]' /> Waikato</p> Anything below is not in a form <p><input type="checkbox" name="agree[]" /> Taranaki</p> <p><input type="checkbox" name="agree[]" /> Taupo</p> <p><input type="checkbox" name="agree[]" /> Wellington/p> <p><input type="checkbox" name="agree[]" /> Bay of Plenty</p> <p><input type="checkbox" name="agree[]" /> Manukau</p> <p><input type="submit" value="submit" onclick="form2.submit();"/></p> </div> </form> Your first form has no submit button Edited October 12, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/282830-i-put-different-action-but-when-i-hit-submit-it-still-bring-me-to-the-same-page/#findComment-1453648 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.