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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.