duanguanzai6181 2011-05-17 23:59
浏览 37

如何在表单提交上处理PHP会话更新?

Hey Guys, I have this form that when I submit will put into a session variable the items in the form. The form has a self target so after clicking submit, it just refreshes the page.

But I need the page to be refreshed with the newly added session variable items to be echo'd back out. Currently I would need to click refresh again for it to echo out because the session was updated on the 1st session and not yet available until the next page reload.

So how can I achieve what I want? I hope this makes sense...

thanks!

  • 写回答

3条回答 默认 最新

  • dsbpaqt61965 2011-05-18 00:05
    关注

    It sounds like you're just wanting to be able to know if the form was submitted?

    <?php
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        session_start();
        $_SESSION['field1'] = $_POST['field1'];
        echo "field1 = " . $_SESSION['field1'];
    } else {
        // show form here
    }
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM