doujieju0397 2016-02-21 06:12 采纳率: 0%
浏览 102
已采纳

网站的PHP登录错误

This code on my website doesn't seem to work. It gives an error 500 and the error log in Apache says there is a syntax error. Any advice? I got this code from a YouTube video. Here is the link: https://www.youtube.com/watch?v=Z_uOXYFVqOE&list=PLC89FC77EBA1595F4&index=2

<?php

session_start();

$username = $_POST['username'];
$password = $_POST['password'];

if ($username&&$password)
{

    $connect = mysql_connect("192.168.0.17","root","***************") or die ("Unable to connect to MySQL!  Contact the admin.");
    mysql_select_db("login") or die ("Unable to find to database!  Contact the admin.");

    $query = mysql_query("SELECT * FROM users WHERE username='$username'");

    $numrows = mysql_num_rows($query);
    if ($numrows !=0)
        {

            while ($row = mysql_fetch_assoc($query))
            {

                $dbusername = $row['username'];
                $dbpassword = $row['password'];

            }
            if ($username==$dbusername&&$password==$dbpassword)
            {

                echo "Logged in! <a href='membersarea'>click here to enter the members area</a>"
                $_SESSION['username']=$dbusername;

            }
            else 
                echo "Incorrect username and/or password.";
        }

        else
            die ("Incorrect username and/or password.");
}
else
    die ("Please enter a username and password")

?>
  • 写回答

2条回答 默认 最新

  • duanmeng9336 2016-02-21 06:48
    关注

    You need to add a semi-colon ; at these lines:

    echo "Logged in! <a href='membersarea'>click here to enter the members area</a>";
    

    AND

    die ("Please enter a username and password");
    

    Also, referring to the video, <a href='membersarea'> should be <a href='membersarea.php'> instead.

    Read up more on PHP Syntax: http://www.w3schools.com/php/php_syntax.asp.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?