donglusou3335 2015-02-18 20:23
浏览 31
已采纳

创建会话cookie并在最终页面中发布

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!

  • 写回答

1条回答 默认 最新

  • 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">
    </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...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码