简体   繁体   English

PHP变量无法打印

[英]PHP variable won't print

I have an html file with a form (with method=get) with inputs that takes a username with name user , and password pwd . 我有一个HTML文件,其格式为(带有method = get),其输入带有名称为user的用户名和密码pwd The submit button then directs to a file called admin.php which looks like this: 然后,“提交”按钮将定向到名为admin.php的文件,如下所示:

admin.php: admin.php:

<html>
<body>
<?php
    echo "user: $user";
?>
</body>
</html>

I can see the variables in the url being passed over, but when I load my admin.php it only prints user: and nothing else. 我可以看到传递过来的url中的变量,但是当我加载admin.php时,它仅显示user:而没有其他显示。 I know this is probably a stupid question, but why is this so? 我知道这可能是一个愚蠢的问题,但是为什么会这样呢?

这将使其工作。

$user = $_GET['user'];

尝试像这样打印:

echo "user: " . $_GET['user'];
echo "user: " . $_POST['user'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM