0

I have a form "A" where visitors enter color of outfit chosen, then form "B" where they enter other infos like measurements and other specifications. Now, instead of posting the two forms separately, i want after they fill and submit form A, a page (verNote.php) creates a session cookie to store the entry, and proceeds to the form B.

After filling form B, when posting infos on form B, it should call infos from form A stored via session cookies and add to the inputs to POST.

When i use the code below, i dont get the inputs from form A posted on submit of the final page.

Below is my (verNote.php)

<?php

ini_set('session.save_path', 'tmp');
session_start();
$chosenColour = $_POST['chosenColour'];
$chosenMatch = $_POST['chosenMatch'];
$ip = getenv("REMOTE_ADDR");
$_SESSION['chosenColour'] = $chosenColour;
$_SESSION['chosenMatch'] = $chosenMatch;
setcookie("chosenColour", $chosenColour, time()+3600);
setcookie("chosenMatch", $chosenMatch, time()+3600);
header("Location: formB.php");

?>

Form A has just 2 entries, while B has 4 entries, and they post perfectly if i decide to post them independently. But i want both entries in both A and B to be submitted once.

Sorry, this is best info i can make available. will appreciate assistance on how to effectively achieve this. Ruse!

7
  • Please include you form code too...
    – Moid
    Feb 18, 2015 at 20:28
  • ok..do these forms exist on same page..?
    – Moid
    Feb 18, 2015 at 20:37
  • no, formA.php and formB.php, both on same folder tho.
    – Ruse Yee
    Feb 18, 2015 at 20:42
  • Just curious..why are are you using two forms on a same page..?
    – Moid
    Feb 18, 2015 at 20:44
  • You dont seem to get me, i am NOT using two forms on same page. Read my post carefully. i have 2 different pages both with one form each.
    – Ruse Yee
    Feb 18, 2015 at 20:47

1 Answer 1

0

Here it goes:

On A.php

<form action="B.php" method="POST">
    <input type="text" name="name">
    <input type="text" name="sex">
    <input type="submit" value="Submit">
</form>

On B.php

<form action="verNote.php" method="POST">
    <input type="text" name="color">
    <input type="text" name="measure">
    <input type="hidden" name="name" value="<?php echo $_POST['name'] ?>" >
    <input type="hidden" name="sex" value="<?php echo $_POST['sex'] ?>" >
    <input type="submit" value="Submit">
</form>

On verNote.php simply get all the values using POST. Try somthing like this...it will work...

Your verNote.php will be something like this..

<?php
echo $_POST['name'];
echo '<br>';
echo $_POST['sex'];
echo '<br>';
echo $_POST['color'];
echo '<br>';
echo $_POST['measure'];

I have completely tested this code...And I am to receive 4 values at the end... If it doesn't work, might be something else in your code then...

1
  • Didnt work. With this, i only got entries of form B submitted.
    – Ruse Yee
    Feb 18, 2015 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.