KenHorse Posted February 27, 2013 Share Posted February 27, 2013 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? 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 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. 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> "; ?> 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 Link to comment https://forums.phpfreaks.com/topic/274994-wierd-problem/#findComment-1415269 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.