I'm trying to create a simple php login system. And even if the username & password exists in the database, it doesn't work but shows "invalid username & password" error message.
<?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!";
}
?>
What am I doing wrong here?
Change
$password=$_POSt['password'];
to
$password=$_POST['password'];
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments