从动态生成的 html 发送的 php 中未捕获 Post 变量

发布于 2024-11-30 21:03:37 字数 492 浏览 2 评论 0原文

我有一个非常简单的问题,但我环顾四周,由于某种原因无法调试它,有人能指出我正确的方向吗?

我有一个 php 脚本,它动态生成一个链接

 <?php
  $id = 1;

  echo "<a href='http://www.example.com/page.php?id='$id'>click link</a>"

 ?>

在 example.php 上我有...

 $userId = $_POST['id'];

 then I insert $userId query...
 ?>

由于某种原因,Post vairable 不是由 example.php 脚本引起的,我可以在页面顶部的 URL 中看到它,但它们不会让 php 产生甜蜜而热情的爱。有什么想法吗?我会提到我是在 IFRAME 中执行此操作,但是我简单地尝试了一下并得到了相同的结果:(

Im having a really simple issue but iv looked around and cant debug it for some reason, can someone point me in the right direction??

I have a php script which dynamically generates a link

 <?php
  $id = 1;

  echo "<a href='http://www.example.com/page.php?id='$id'>click link</a>"

 ?>

On example.php I have...

 $userId = $_POST['id'];

 then I insert $userId query...
 ?>

For some reason the Post vairable is not being cause by the example.php script I can see it in the URL at the top of the page but they wont make sweet passionate php love. Any thoughts? I will mention I am doing this from within an IFRAME however I tried it simply and got the same result :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

久夏青 2024-12-07 21:03:37

我认为您的意思是,在 page.php 上您有...

如果是这种情况,您将在 GET 中发送 id 参数,而不是 POST。要在其他页面中访问它,您需要使用:

$userId = $_GET['id'];

I think you mean, on page.php you have...

If that is the case, you are sending the id parameter in a GET, not a POST. To access it in your other page you need to use:

$userId = $_GET['id'];
陌生 2024-12-07 21:03:37

您的变量位于 $userId = $_GET['id']; 中。
另一个问题是 ' 符号混乱:应该是

echo "<a href='http://www.example.com/page.php?id=$id'>click link</a>"

your variable is in $userId = $_GET['id'];.
another problem is a mess with ' symbols: should be

echo "<a href='http://www.example.com/page.php?id=$id'>click link</a>"
陌伤ぢ 2024-12-07 21:03:37

抱歉,您是通过 GET 发送数据,而不是

通过 $_GET['id']; POST 访问它;

Sorry, but you ar sending data via GET NOT POST

access it via $_GET['id'];

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文