从动态生成的 html 发送的 php 中未捕获 Post 变量
我有一个非常简单的问题,但我环顾四周,由于某种原因无法调试它,有人能指出我正确的方向吗?
我有一个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您的意思是,在
page.php
上您有...如果是这种情况,您将在 GET 中发送
id
参数,而不是 POST。要在其他页面中访问它,您需要使用: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'];
中。另一个问题是 ' 符号混乱:应该是
your variable is in
$userId = $_GET['id'];
.another problem is a mess with ' symbols: should be
抱歉,您是通过 GET 发送数据,而不是
通过 $_GET['id']; POST 访问它;
Sorry, but you ar sending data via GET NOT POST
access it via $_GET['id'];