-1

我有处理用户然后将他们重定向到用户主页的这段代码。

<?php
    $username = $_POST['username'];
    $password = $_POST['pwd'];

    $file = file_get_contents("userdb.html");
    if(!strpos($file, $username)) {
        echo "Your username was not found in our database. Please go back and try again.";
    } else {
        echo "Redirecting...";
        if (md5($password) == !strpos($file, (md5($password))) {
             echo "Redirecting..."
             header ('Location: ./userhome.php')
        } else {
             print "Whoops! Your password seems to be incorrect. Go back and try again."
        }
    }
?>

我得到了错误:

Parse error: syntax error, unexpected '{' in userprocess.php on line 11

有人可以告诉我这个问题吗?我认为这可能是 if 语句中的 if ,但我能做些什么来替代?谢谢。

4

4 回答 4

4

首先,这一行缺少一个右括号:

if (md5($password) == !strpos($file, (md5($password))) {

计算()- 他们需要匹配的数量。

当你修复这个问题时,你仍然会得到错误,因为 PHP 语句需要以分号结尾。

以下所有行都缺少分号:

echo "Redirecting..."
header ('Location: ./userhome.php')
print "Whoops! Your password seems to be incorrect. Go back and try again."

您需要先修复它们,然后才能在没有语法错误的情况下运行程序。

希望有帮助。

于 2011-08-14T21:18:15.450 回答
1

改变

if (md5($password) == !strpos($file, (md5($password)))

if (md5($password) == !strpos($file, md5($password)))
于 2011-08-14T21:14:33.683 回答
1

您在该行中缺少右括号:

if (md5($password) == !strpos($file, (md5($password))) {
于 2011-08-14T21:15:02.700 回答
1
<?php
    $username = $_POST['username'];
    $password = $_POST['pwd'];

    $file = file_get_contents("userdb.html");
    if(!strpos($file, $username)) {
        echo "Your username was not found in our database. Please go back and try again.";
    } else {
        echo "Redirecting...";
        if (md5($password) == !strpos($file, md5($password))) {
             echo "Redirecting...";
             header ('Location: ./userhome.php');
        } else {
             print "Whoops! Your password seems to be incorrect. Go back and try again.";
        }
    }
?>
于 2011-08-14T21:17:16.640 回答