I'm redesigning a webpage due to new PHP-version (PHP 7.2), and have to make a new login script (see below)
The script below returns OK when I'm entering correct username and password.
But, when I try to add sessions and more variables after the $message="ok" (and before the else), the script goes down and returns a HTTP ERROR 500. In the log it says "PHP Parse error: syntax error, unexpected 'else'" on the else between the $message.
I'm in a huge need of making it work with sessions and variables.
Do anyone have any clue on how I fix this so I can add sessions and so on to make this script work further on?
session_start();
$conn = mysqli_connect("localhost","username","password","database") or die($link);
$message="";
if(!empty($_POST["login"])) {
{
$result = mysqlI_query($conn,"SELECT * FROM logintable WHERE username='" . $_POST["user_name"] . "'");
$row = mysqli_fetch_array($result);
$hashpw = $row['password'];
if(password_verify($_POST["password"],$hashpw))
$message="OK";
else
$message="WRONG";
}
}
if(!empty($_POST["logout"])) {
$_SESSION["user_id"] = "";
session_destroy();
}