-1

我有以下 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> 
4

3 回答 3

6

你忘了一个$

if( $arr[$username] == $password){
    ^
    |- here
于 2012-05-31T08:19:21.023 回答
3

改变这一行:

if(arr[$username] == $password){

对此:

if($arr[$username] == $password){
于 2012-05-31T08:20:45.023 回答
2
if($arr[$username] == $password){

错误信息为您提供发生错误的行,只需检查该行。

于 2012-05-31T08:20:20.883 回答