dshm8998473 2014-06-11 17:37
浏览 22
已采纳

一个PHP脚本,它从表单接收POST信息,接收它们,添加它们并传递它们

A fairly basic question, I'm looking to know which is the proper way of doing it.

I can create an html form where the user can put his/her input and then passes them (action=http://...) into a php script.

I can create a php script that receives these data and stores them as variables:

..
$name = $_POST['name'];
$email = $_POST['email'];
..

Now, I wanna take these variables (plus some more pre-defined in this very script) and automatically "post" these fields into different address that would further handle them. (by "post", I mean the exact same way the html form "posted" these fields into this script to begin with)

To make it a little clearer: this problem wouldn't exist if I were to include all the need values as hidden fields in the script and asked the user to click "submit", I'm basically looking for a way to make the typical (html => form => fields => Post) happen automatically.

Your help is very appreciated.

  • 写回答

1条回答 默认 最新

  • dt102282 2014-06-11 18:18
    关注

    You could store them in a session and access them later. That way the user isn't able to see the values, like they would if you used hidden fields.

    Declare them like this:

    <?php
    
    session_start(); //START THE SESSION
    
    $_SESSION['name'] = $_POST['name'];
    $_SESSION['email'] = $_POST['email'];
    
    ?>
    

    Then whenever you want to access them, on any script, use $_SESSION['name'] or $_SESSION['email']. BUT you always have to declare session_start(); on every page/script you want to access them on.

    Read up on PHP sessions here: The PHP Manual

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

报告相同问题?

悬赏问题

  • ¥15 聚类分析或者python进行数据分析
  • ¥15 如何用visual studio code实现html页面
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?