I figured it out by myself thanks Im having trouble getting my php login script to work. I pretty sure there is some syntax wrong with my code and I need some help to see what I'm doing wrong. Can someone help me with that I'm doing wrong with my code because I'm lost?
What I'm trying to do it that when the user signs in, I will search the database for the username that they have entered and once they have found it, it will find the password and decrypt it.
<!DOCTYPE html>
<html>
<head>
<title>
login
</title>
</head>
<body>
<?php
session_start();
// Authenticates existing users
?>
<form method="post" action="login.php">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
<input type="submit" value="Login">
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
// Connect to the database
$mysqli = new mysqli("localhost", "bwright4", "H01597127", "bwright4");
// Output error info if there was a connection problem
if ($mysqli->connect_errno)
die("Failed to connect to MySQL: ($mysqli->connect_errno) $mysqli->connect_error");
//Username information
$username = mysql_real_escape_string($_POST['username']);
// Check username and password
$password = $_POST["password"];
$password_hash = password_hash($password, PASSWORD_BCRYPT);
// bcrypt hash for "abc"
$actual_hash = '$2y$10$yd/WAu0wdbgzPk0TDNVBf.MZ0TD6pwKLM18O73aAwOdYs4291/wha';
$sql = mysql_query("SELECT * FROM users_table WHERE username='$username'");
if(mysql_num_rows($sql) == 1)
{
$row = mysql_fetch_array($sql);
if (password_verify($password, $actual_hash))
{
$_SESSION["login"] = "True";
header("Location: index.php");
exit;
}
else
echo "<p>Wrong password</p>";
}
}
?>
<body>
</html>