【问题标题】:passing hidden input through post is not working (PHP and html)通过帖子传递隐藏输入不起作用(PHP和html)
【发布时间】:2022-01-21 06:05:11
【问题描述】:

嗨,我正在处理以下代码,它将从查询中获取一个值,我想将变量的值传递给另一个 php 页面,该页面将执行一些语句。

这是我的表格:

  <form method="post" >    
   <input  type="hidden" name="id" value="<?php echo $orderId; ?>"  />
     <button  type="submit" class="button" name="Reorder" value="Reorder">Reorder </button>
    </form>

这里是接收数据的页面,我将从表单中提取它们:

extract($_POST); 
$orderId=$_POST['id'];

这是错误: 注意:未定义索引:id

【问题讨论】:

  • 这不会将用户提交到另一个页面。您如何将用户发送到页面?不要使用extract
  • @user3783243 我不会将用户发送到另一个页面,第二个页面只会获取数据来做一些陈述,因为它是一个表单,我需要在它上面做一些事情,它必须使用 get 或 post 之类的方法
  • 我不关注。您在评论和问题正文中自相矛盾。 i am not sending the user to another page the second page will just get the data,也不是i want to pass the value of the variable to another php page.. 所以只有1页还是2页??如果您多次声明 2 用户如何/何时到达那里?
  • 在第1页:用户不会输入任何数据,他/她只需点击按钮,在第二个php页面将收到隐藏的输入值来执行一些语句
  • &lt;form method="post" &gt; 不会将用户发送到任何地方。您是使用 JS 将用户发送到下一页还是他们如何到达那里?

标签: php html forms


【解决方案1】:

您的表单没有操作方法。据你说,数据正在发送到另一个页面。

action = "validate.php"

而且你也没有检查按钮是否isset

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2012-02-10
    相关资源
    最近更新 更多