我有以下process.php文件:
<html>
<head>
<title> Form Processing </title>
</head>
<body>
<?php
// print _r($_POST)
$arr=array
(
"ana" => "ana123",
"gogi"=>"2345",
"vano"=>"3at4"
);
$username=$_POST['username'];
$password=$_POST['password'];
if(arr[$username] == $password){
echo " you entered correct input for ana ";
}
else
{
echo " try again ";
}
?>
</body>
</html>
当我运行此代码时,它写道:
Parse error: syntax error, unexpected '[' in C:\xampp\htdocs\datuna\process.php
on line 17
但遗漏的地方[我无法理解,我正在尝试检查用户是否输入了正确的用户名和密码,如果您需要,这里也是这个文件:
<html>
<head>
<title>FORMS</title>
</head>
<body>
<form action="process.php" method="post">
Username : <input type=text name=username value="" /> <br/>
Password : <input type=password name=password value="" /><br/>
<input type="submit" name=submit value=submit />
</form>
</body>
</html>
答案 0 :(得分:6)
您忘记了$
:
if( $arr[$username] == $password){
^
|- here
答案 1 :(得分:3)
更改此行:
if(arr[$username] == $password){
到此:
if($arr[$username] == $password){
答案 2 :(得分:2)
if($arr[$username] == $password){
错误信息为您提供了发生错误的行,只需检查该行。