budimir Posted September 13, 2008 Share Posted September 13, 2008 Hey Guys, Quick question. I have two forms on my page. On first one i use javascript onChange event to execute PHP_SELF. And second one should get all the values from the first one and second one and send all the data to (here I use classic method="POST" action="data.php")data.php file. But, the problem is it's not getting data from the first form. How can I make it so both forms are collected when I hit Submit button? I'm stuck!!! Link to comment https://forums.phpfreaks.com/topic/124052-solved-two-forms-problem/ Share on other sites More sharing options...
gaza165 Posted September 13, 2008 Share Posted September 13, 2008 can u not use just 1 form for all the data?? what about storing values of the forms in session variables and then when they are all passed destroy the session? Link to comment https://forums.phpfreaks.com/topic/124052-solved-two-forms-problem/#findComment-640404 Share on other sites More sharing options...
budimir Posted September 13, 2008 Author Share Posted September 13, 2008 That looks a little bit too complicated for me, because I already use ssession for diferent things, so I can not destroy it. Let me help with this. I have come up with a different idea. I would use one form and use action=PHP_SELF, becasue I need it for some onChange events and on the bottom of the page I would use submit button to send the complet form when everything is filled out. And then use php if function like this: if ($_POST["submit "] == submit){ header("Location:store_values.php"); exit; } else { echo "Error!"; } Now, my question is. On store_values.php I have $values = $_POST["values"]; where I'm getting everything from form and putting it in a query. Will that work??? Link to comment https://forums.phpfreaks.com/topic/124052-solved-two-forms-problem/#findComment-640409 Share on other sites More sharing options...
gaza165 Posted September 13, 2008 Share Posted September 13, 2008 yes that should work... the code to check if the submit button is pressed is simply <?php if ($_POST["submit "]) { header("Location:store_values.php"); exit; } else { echo "Error!"; } ?> you will also need a redirect in store_values.php to take the user somewhere else once the queries have been executed.. let me know how u get on.. put your full code on so i can see what your form looks like Link to comment https://forums.phpfreaks.com/topic/124052-solved-two-forms-problem/#findComment-640413 Share on other sites More sharing options...
budimir Posted September 13, 2008 Author Share Posted September 13, 2008 Yep, that will probably work! I have header errors now. I need to check where I'm getting an output. Thanks a lot. I need to play with it now, but I will mark this as solved since my original question is resolved now!!! Link to comment https://forums.phpfreaks.com/topic/124052-solved-two-forms-problem/#findComment-640419 Share on other sites More sharing options...
gaza165 Posted September 13, 2008 Share Posted September 13, 2008 u need to put the if statement at the top of the page so it will check it first.. u wont get the header errors then. Link to comment https://forums.phpfreaks.com/topic/124052-solved-two-forms-problem/#findComment-640421 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.