Wstar Posted March 23, 2007 Share Posted March 23, 2007 I can not find out whats wrong here. It's most likely something small that I've over looked. I have multiple submit buttons on a forum using the following code: if ($action=='edit') { echo '<input type="submit" name"update" value="Update">' . ' '; echo '<input type="submit" name"cancel" value="Cancel">'; } else { echo '<input type="submit" name"delete_confirmed" value="Delete">' . ' '; echo '<input type="submit" name"update" value="Update">' . ' '; echo '<input type="submit" name"cancel" value="Cancel"></form>'; } At the top of the .php file I have the following: if(isset($cancel)){ $action=''; } elseif(isset($add)) { $message="Files stored successful."; } elseif(isset($delete_confirmed)) { $message="Files has been deleted."; } elseif(isset($update)) { $message="Files stored and updated successful."; } Now, when the forum is submitted by hitting the add button, nothing is stored in $message. Later in the code (start of a table for a header) I have: <?=$message?> My form declaration is: <form enctype="multipart/form-data" method="post" action="news.php"> Why are my submit buttons NOT working? Quote Link to comment Share on other sites More sharing options...
interpim Posted March 23, 2007 Share Posted March 23, 2007 try using different forms with seperate actions for each button... Looks to me like you have several buttons in 1 form, essentially doing whatever action that form is telling it. Quote Link to comment Share on other sites More sharing options...
Hell Toupee Posted March 23, 2007 Share Posted March 23, 2007 Depending on what variables you've declared set or php version you're running,trying this might help: if(isset($_REQUEST['cancel'])){ $action=''; } elseif(isset($_REQUEST['add'])) { $message="Files stored successful."; } elseif(isset($_REQUEST['delete_confirmed'])) { $message="Files has been deleted."; } elseif(isset($_REQUEST['update'])) { $message="Files stored and updated successful."; } Also: <?php echo($message); ?> Quote Link to comment Share on other sites More sharing options...
Wstar Posted March 23, 2007 Author Share Posted March 23, 2007 Thanks for the quick replies. I know its not a problem with <?=$message?> because I've just tried this. if(isset($_REQUEST['test1'])){ echo "Test 1"; } elseif(isset($test2)) { echo "Test 2"; } <form enctype="multipart/form-data" method="post" action="news.php"> <input type="submit" name"test1" value="Test 1"> <input type="submit" name"test2" value="Test 2"> </form> Nothing gets echo'ed in either case. I'm just not understanding this problem. Quote Link to comment Share on other sites More sharing options...
Hell Toupee Posted March 23, 2007 Share Posted March 23, 2007 If in no case it gets echoed, than that mean there's a greater chance there's a problem with " <?=$message?>", try changing it aswell as the issets to $_REQUEST and see. Quote Link to comment Share on other sites More sharing options...
Wstar Posted March 23, 2007 Author Share Posted March 23, 2007 Still nothing. Here is my form code in html. <form enctype="multipart/form-data" method="post" action="news.php"> <input type="submit" name"test1" value="Test 1"> <input type="submit" name"test2" value="Test 2"> </form> Here is the php code for submitting. I've tried doing each of these (one at a time): if($_REQUEST['test1']){ echo "It WOrked!"; } else { echo "It DIDNT WOrked!"; } AND if(isset($_REQUEST['test1'])){ echo "It WOrked!"; } else { echo "It DIDNT WOrked!"; } AND if(isset($test1)){ echo "It WOrked!"; } else { echo "It DIDNT WOrked!"; } Still no luck. Quote Link to comment Share on other sites More sharing options...
janroald Posted March 23, 2007 Share Posted March 23, 2007 Hehe, was pussled there for a while when I didn't get it to work myself :-) You see what's wrong here? : name"test1" I'm the man :-) Quote Link to comment Share on other sites More sharing options...
janroald Posted March 23, 2007 Share Posted March 23, 2007 Next time, when you have a similar problem, make the form method GET, then you can see for yourself what data is sent. Quote Link to comment Share on other sites More sharing options...
Wstar Posted March 23, 2007 Author Share Posted March 23, 2007 Bah, I knew it was simple and I was over-looking it. Thank you SO much! Now I'm going to go hide in shame for such a simple error!! Thanks for everyones help! Quote Link to comment Share on other sites More sharing options...
janroald Posted March 23, 2007 Share Posted March 23, 2007 No need for shame m8, we all waste hours this way from time to time :-) You just need to get better in trying to isolate the problem step by step. I copy/pasted your code, and when I didn't get it to work the way you wanted it to, i changed the method to GET. I then got "?test1" in the url. Problem was then easily found :-) 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.