PHP登录“无效的用户名和密码”

时间:2014-09-24 07:59:55

标签: php

我正在尝试创建一个简单的php登录系统。即使用户名和&密码存在于数据库中,它不起作用,但显示“无效的用户名和密码”错误消息。

<?php
session_start();

    $con=mysqli_connect("localhost","root","");
    mysqli_select_db($con,"server2go");

    if(mysqli_connect_errno())
        echo "<h2>Failed to connect to MySQL database!".mysqli_connect_errno();

    if(isset($_POST['submit']))
    {   
        $username=$_POST['username'];
        $password=$_POSt['password'];   

        $sql=mysqli_query($con, "SELECT username FROM userlogin WHERE username='$username' AND     password='$password' limit 1 ");

        if(mysqli_num_rows($sql)==1)
        {                           
            $data=mysqli_fetch_array($sql,1);
            $_SESSION['username']=$data['username'];
            header("location:dashboard.php");               
        }
        else             
            $error="Invalid username or password!";         
    }
?>

我在这里做错了什么?

1 个答案:

答案 0 :(得分:1)

更改

$password=$_POSt['password'];

$password=$_POST['password'];