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? Quote Link to comment 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 ?> Quote Link to comment Share on other sites More sharing options...
supanoob Posted July 8, 2007 Author Share Posted July 8, 2007 thanks Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 8, 2007 Share Posted July 8, 2007 mark it solved please Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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>"; ?> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 8, 2007 Share Posted July 8, 2007 what is $_GET['step'] ?? Quote Link to comment 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\"> Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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.