2015-02-18 20:23 阅读 29


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)


ini_set('session.save_path', 'tmp');
$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!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dtwd74916 dtwd74916 2015-02-18 21:13

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

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

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

    Your verNote.php will be something like this..

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

    点赞 评论 复制链接分享