KenHorse Posted February 27, 2013 Share Posted February 27, 2013 (edited) I'm trying to work out a problem with a suite of scripts and wrote a very simply "test" script to see if I could figure out what I'm doing wrong in another place. Here's my test one: <?php $id = 776; print '$id ' . "$id\n"; if(isset($POST['cancel'])){ print "Exiting"; exit(); } if(isset($_POST['submitted'])){ print '$id ' . "$id"; } print " <input type=\"submit\" value=\"Save\" name=\"submitted\"> <input type=\"submit\" value=\"Cancel\" name=\"cancel\"> "; ?> Normally $id is read in from a MySQL database and some of the above code appears in a script (as a pop up) referenced by another script. So I'm assigning $id in my test instead of reading it at the time the script is first run. Anyway... the script loads fine in a browser with the first print statement properly showing "$id 776". Howver clicking either the Save or Cancel buttons do nothing at all. What am I doing wrong? Edited February 27, 2013 by KenHorse Quote Link to comment https://forums.phpfreaks.com/topic/274994-wierd-problem/ Share on other sites More sharing options...
requinix Posted February 27, 2013 Share Posted February 27, 2013 (edited) Besides the $POST['cancel'] typo, the buttons have to be in a form. $id = 776; print '$id ' . "$id\n"; if(isset($POST['cancel'])){ print "Exiting"; exit(); } if(isset($_POST['submitted'])){ print '$id ' . "$id"; } print " </pre> <form method='\"post\"'> </form> <br>";<br [edit] Oookay, indentation doesn't want to work for me. Edited February 27, 2013 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/274994-wierd-problem/#findComment-1415267 Share on other sites More sharing options...
QuickOldCar Posted February 27, 2013 Share Posted February 27, 2013 I added form to it, also you didn't have $_POST['cancel'] <?php $id = 776; print '$id ' . "$id\n"; if(isset($_POST['cancel'])){ print "Exiting"; exit(); } if(isset($_POST['submitted'])){ print '$id ' . "$id"; } print " <form action=\"\" method=\"post\"> <input type=\"submit\" value=\"Save\" name=\"submitted\"> <input type=\"submit\" value=\"Cancel\" name=\"cancel\"> </form> "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/274994-wierd-problem/#findComment-1415268 Share on other sites More sharing options...
QuickOldCar Posted February 27, 2013 Share Posted February 27, 2013 lol@requinix, at least we gave same advice Quote Link to comment https://forums.phpfreaks.com/topic/274994-wierd-problem/#findComment-1415269 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.