Im new to PHP and im trying to code a developer password on my website. The issue im having is that it continues to login with any password. How can I fix this? The Current password I have set in 12345. It even logins with nothing entered.
Here is the Code for my login checker -
<html>
<head>
<title>Login Check</title>
<link rel="stylesheet" href="style.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<?php
$host="localhost";
$username="root";
$password="password";
$db_name="mydb";
$tbl_name="dev";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$mypassword=$_POST['mypassword'];
$mypassword = stripslashes($mypassword);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE password='$mypassword'";
$result=mysql_query($sql);
if($mypassword == $password){
$_SESSION['password']= $mypassword;
header("location:index2.php");
}
else {
echo "Wrong Password";
}
?>
</body>
</html>