Jump to content

[SOLVED] Two forms problem?


budimir

Recommended Posts

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

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???

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.