我有以下非常基本的PHP脚本:
<?php
$username = $_POST['username'];
$password = $_POST['password'];
echo "This is the username: ";
echo $username;
?>
这是输出:
This is the username:
我的网址中有我的用户名和密码参数。为什么不回显用户名?
它不会显示,因为URL中的参数被解析为GET而不是POST。
使用$_GET['username']
从http://www.somesite.com?username=yash
获取数据
参考:
尝试回显整个$ _POST数组。这可能会导致您遇到问题。
echo "<pre>".print_r($_POST,true)."</pre>";