lindm Posted September 20, 2007 Share Posted September 20, 2007 I have a form which should be submitted with either of two actions. Tried with javascript but this seems unreliable. Now looking at php and a processor page as the action of the form (process.php) which then sends the user to the different actionpages...can't figure out how to forward the post-variables to the different pages... Example process.php <?php if(array_key_exists('goto1', $_REQUEST)) { CODE FOR GOTO goto1.php } else if(array_key_exists('goto2', $_REQUEST)) { CODE FOR goto2.php } ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2007 Share Posted September 20, 2007 It depends on how you're selecting which action? Do you have two submit buttons? A drop down? What? Quote Link to comment Share on other sites More sharing options...
lindm Posted September 20, 2007 Author Share Posted September 20, 2007 Yes two different submit buttons with the name/id goto1 and goto2. Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2007 Share Posted September 20, 2007 So on the top of your processing page, do print_r($_POST); and click on one of the buttons. See what it says. Then go back and click on the other, and see what it says now. Also, make sure they have values as well. value="action1" and value="action2" Quote Link to comment Share on other sites More sharing options...
lindm Posted September 20, 2007 Author Share Posted September 20, 2007 Well it shows [goto1] => Value1 So ID/NAME => Buttonvalue Would the code be more like <?php if($_POST[goto1]=Value1) { CODE TO POST $_POST to goto1.php } else if($_POST[goto2]=Value2)) { CODE TO POST $_POST to goto2.php } ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2007 Share Posted September 20, 2007 <?php if(isset($_POST['goto1']){ //do the first }else{ //do the second } ?>[code] [/code] Quote Link to comment Share on other sites More sharing options...
lindm Posted September 20, 2007 Author Share Posted September 20, 2007 Alright, what should //do the first be replaced by? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2007 Share Posted September 20, 2007 oh for pete's sake. Your code! That you want to use if they press the first button! Quote Link to comment Share on other sites More sharing options...
MmmVomit Posted September 20, 2007 Share Posted September 20, 2007 Well it shows [goto1] => Value1 So ID/NAME => Buttonvalue Would the code be more like <?php if($_POST[goto1]=Value1) { CODE TO POST $_POST to goto1.php } else if($_POST[goto2]=Value2)) { CODE TO POST $_POST to goto2.php } ?> You could use redirects to "goto1.php" and "goto2.php", but I think a better solution would be to simply implement all the functionality you're looking for in one page. Quote Link to comment Share on other sites More sharing options...
lindm Posted September 21, 2007 Author Share Posted September 21, 2007 Was hoping to find an easy php solution but got my javscript working now: function changeAction(){ var x=document.forms.form x.action="writeformsie.php" document.form.submit(); } Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 21, 2007 Share Posted September 21, 2007 topic solved click it please 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.