220061
Well-Known Coder
Hello, I don't really know how to explain this but right now when I submit it stays on the loginback page andit gives me a blank screen? why is it doing this? I have already tried to display the error messages by using
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
but it doesn't tell me anything?
code:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
but it doesn't tell me anything?
code:
PHP:
<?php
// dit is allemaal nog niet veilig
session_start();
// Check if the user is already logged in, if yes then redirect him to welcome page
if(isset($_POST["email"]) && $_POST["password"] === true){
header("location: welcome.php");
exit;
}
// Include config file
include "config.php";
$email = mysqli_real_escape_string($conn , $_POST['email']);
$password = mysqli_real_escape_string($conn , $_POST['password']);
$stmt = $conn->prepare("SELECT user_id, email, password FROM users WHERE email=? AND password=? LIMIT 1");
if ($stmt->num_rows === 1) {
$row = $stmt->fetch_array(MYSQLI_ASSOC);
if (!password_verify($password, $row['password'])) {
// invalid = run set of functions
echo "This is false";
header( "refresh:5;url=login.php" );
}
else {
// login
if($stmt->num_rows == 1) //To check if the row exists
{
if($stmt->fetch()) //fetching the contents of the row
{
// $_SESSION['Logged'] = 1;
$_SESSION['user_id'] = $user_id;
$_SESSION['username'] = $username;
echo 'Success!';
header("Location: welcome.php");
}
else {
echo "INVALID USERNAME/PASSWORD Combination! You will be send back in 5 seconds 1";
header( "refresh:5;url=login.php" );
}
$stmt->close();
}else{
echo "INVALID USERNAME/PASSWORD Combination! You will be send back in 5 seconds 2";
header( "refresh:5;url=login.php" );
}
}
}
$stmt->bind_param('ss', $email, $password);
$stmt->execute();
$stmt->bind_result($user_id, $email, $password);
$stmt->store_result();
$conn->close();
?>