我写了这段代码,执行时我得到的只是白屏
我检查了旧问题,并尝试了
之类的许多解决方案ini_set('display_startup_errors',true);
error_reporting(E_ALL);
ini_set('display_errors',true);
<?php
$host = "localhost";
$username = "root";
$password = "";
$dbname = "users";
try {
$connexion = new PDO("mysql:host=$host;dbname=$dbname",$username, $password);
$connexion -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e) {
echo $e->getMessage();
}
ini_set('display_startup_errors', true);
error_reporting(E_ALL);
ini_set('display_errors', true);
if (isset($_POST['Connexion'])){
$errMsg = '' ;
$email = $_POST['mail'];
$pass = $_POST['pass'];
if($email == ''){
$errMsg = 'Enter username';
}
if($pass == ''){
$errMsg = 'Enter password';
}
if( $errMsg == '') {
try {
$stmt = $connexion->prepare('SELECT * FROM users WHERE mail = :mail ');
$stmt->execute(array(':mail' => $email ));
$data = $stmt->fetch(PDO::FETCH_ASSOC);
if($data == false ){
$errMsg = "User not found.";
}
else {
if($password == $data['password']) {
$_SESSION['first_name'] = $data['first_name'];
$_SESSION['last_name'] = $data['last_name'];
$_SESSION['password'] = $data['password'];
header('Location: ../profil/profil.php');
exit;
}
else{
$errMsg = 'Password not match.';
}
}
}
catch(PDOException $e) {
$errMsg = $e->getMessage();
}
}
}
?>
这是html页面
<!DOCTYPE html>
<html>
<head>
<title>login page</title>
<meta charset='utf-8'>
<link rel="stylesheet" href="login-html-css-php (2).css">
<link rel="stylesheet" href="BVB-resp.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css"
integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns" crossorigin="anonymous">
</head>
<body>
<form method="POST" action="sign-in.php" >
<div class= login>
<div class = log>
<h1 id="sign-in"> Login </h1>
<div class= A>
<i class="fas fa-envelope"></i>
<input class= type= "email" id = "email" name= "mail" placeholder="mail" >
</div>
<div class= A>
<i class="fas fa-lock"></i>
<input type= "password" id = "pass" name= "pass" placeholder="password">
</div>
<div class= C>
<input type="submit" value= "Connexion" id="disp_button" name="Connexion">
</div>
</div>
</div>
</form>
但浏览器仍显示白页
请提出任何建议,我认为错误来自我的代码
谢谢