doucongmishang2385 2014-04-20 22:08
浏览 5
已采纳

为什么我的表单不能用php / html工作? [关闭]

im trying to pass a variable with a submit button and it doesn't work.

<FORM METHOD="LINK" ACTION=<?php echo "\"add_event.php?email=".$email."\""?>>
<INPUT TYPE="submit" VALUE="add event">
</FORM>

$email is fine in the page that's calling it.

http://localhost/aproject/add_event.php?

that is the url that's passed.

not

http://localhost/aproject/add_event.php?email=myemail@email.com

as I want.

Any thoughts are appreciated.

edit:

the generated html is

<form method="LINK" action="add_event.php?email=closeded@gmail.com">
<input type="submit" value="add event">
</form>
  • 写回答

1条回答 默认 最新

  • dt246813579 2014-04-20 22:10
    关注

    There is no such form method as LINK, so your form is using GET (the default).

    When you submit a GET form, you will destroy any existing query string on the form action and replace it with one generated from the form data.

    Use a hidden input to store your data instead.

    <form action="add_event.php">
      <input type="hidden" name="email" value="<?php echo htmlspecialchars($email); ?>">
      <input type="submit" VALUE="add event">
    </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥23 (标签-bug|关键词-密码错误加密)
  • ¥66 比特币地址如何生成taproot地址
  • ¥20 数学建模数学建模需要
  • ¥15 关于#lua#的问题,请各位专家解答!
  • ¥15 什么设备可以研究OFDM的60GHz毫米波信道模型
  • ¥15 不知道是该怎么引用多个函数片段
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决