supanoob Posted July 8, 2007 Share Posted July 8, 2007 Is it possible to make 1 form lead to 2 different locations depending on what button is pressed? if so how? Link to comment https://forums.phpfreaks.com/topic/58988-solved-1-form-2-locations/ Share on other sites More sharing options...
cooldude832 Posted July 8, 2007 Share Posted July 8, 2007 yes you have to make 2 submit buttons with varying values then do this before the form <?php if ($_POST['submit'] == 'option1') {exit(require('option1.php'));} if ($_POST['submit'] == 'option2') {exit(require('option2.php'));} //etc etc add more for more options ?> Link to comment https://forums.phpfreaks.com/topic/58988-solved-1-form-2-locations/#findComment-292723 Share on other sites More sharing options...
supanoob Posted July 8, 2007 Author Share Posted July 8, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/58988-solved-1-form-2-locations/#findComment-292728 Share on other sites More sharing options...
cooldude832 Posted July 8, 2007 Share Posted July 8, 2007 mark it solved please Link to comment https://forums.phpfreaks.com/topic/58988-solved-1-form-2-locations/#findComment-292733 Share on other sites More sharing options...
supanoob Posted July 8, 2007 Author Share Posted July 8, 2007 it didnt work >< i was still testing when someone marked it solved. Link to comment https://forums.phpfreaks.com/topic/58988-solved-1-form-2-locations/#findComment-292742 Share on other sites More sharing options...
AndyB Posted July 8, 2007 Share Posted July 8, 2007 If it still isn't working, and you want help, post useful parts of your form and form processing code. Link to comment https://forums.phpfreaks.com/topic/58988-solved-1-form-2-locations/#findComment-292743 Share on other sites More sharing options...
supanoob Posted July 8, 2007 Author Share Posted July 8, 2007 sorry my heads all over atm... this is the code that checks the 2 buttons <?php if ($_GET['step'] == 'save_delete') { //delete them if ($_POST['submit'] == 'delete') { $ids_to_delete = $_POST['ids_to_delete']; //Run the delete-query for each entry in the $ids_to_delete array foreach($ids_to_delete as $id_to_delete) { $sql2="UPDATE mail SET mail_deleted='1' WHERE mail_id='$id_to_delete'"; if(mysql_query($sql2)); $sql2="UPDATE accounts SET mail=mail-1 WHERE account_id='$account_id'"; if(mysql_query($sql2)); } echo "Checked Items Deleted."; } //if wanting to save if ($_POST['submit'] == 'save') { $ids_to_delete = $_POST['ids_to_delete']; //Run the delete-query for each entry in the $ids_to_delete array foreach($ids_to_delete as $id_to_delete) { $sql2="UPDATE mail SET mail_saved='1' WHERE mail_id='$id_to_delete'"; if(mysql_query($sql2)); } echo "Checked Mail Saved"; } } ?> and this is the code that has the buttons <?php <input type=\"submit\" value=\"Delete Checked\" name=\"delete\"> <input type=\"submit\" value=\"Save Checked\" name=\"save\"></form></center><br><br>"; ?> Link to comment https://forums.phpfreaks.com/topic/58988-solved-1-form-2-locations/#findComment-292746 Share on other sites More sharing options...
cooldude832 Posted July 8, 2007 Share Posted July 8, 2007 what is $_GET['step'] ?? Link to comment https://forums.phpfreaks.com/topic/58988-solved-1-form-2-locations/#findComment-292749 Share on other sites More sharing options...
supanoob Posted July 8, 2007 Author Share Posted July 8, 2007 something in the url this is the opening of the form <form method=\"POST\" action=\"mail.php?step=save_delete\"> Link to comment https://forums.phpfreaks.com/topic/58988-solved-1-form-2-locations/#findComment-292752 Share on other sites More sharing options...
AndyB Posted July 8, 2007 Share Posted July 8, 2007 <input type=\"submit\" value=\"Save Checked\" name=\"save\"> Just to shorten the time taken to get this working, if you want to test the value sent from that, you want to examine the value of the NAMEd input, i.e. what is $save in the instance above. Link to comment https://forums.phpfreaks.com/topic/58988-solved-1-form-2-locations/#findComment-292754 Share on other sites More sharing options...
nloding Posted July 9, 2007 Share Posted July 9, 2007 If you copied and pasted the HTML for the input button, you forgot to escape the first ". Dunno if that's the problem though. Link to comment https://forums.phpfreaks.com/topic/58988-solved-1-form-2-locations/#findComment-292776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.