【发布时间】:2019-11-23 04:40:54
【问题描述】:
不知道我的错误在哪里,我想根据用户角色重定向到网站的不同部分。
if (isset($_POST['submit'])) {
$stmt = $conn->prepare('SELECT id, password FROM accounts WHERE email = ?');
$stmt->bind_param('s', $_POST['email']);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0) {
$stmt->bind_result($id, $password);
$stmt->fetch();
if (password_verify($_POST['password'], $password)) {
session_regenerate_id();
$_SESSION['loggedin'] = TRUE;
$row = $result->fetch_assoc();
if ($row['role']=='admin') {
header('Location: admin.php');
} else if ($row['role']=='user') {
header('Location: profile.php');
}
} else {
$password_incorrect = '¡Contraseña incorrecta! Si has olvidado tu contraseña puedes <a href="#">restablecerla</a>.';
}
}
【问题讨论】:
标签: php mysql oop authentication mysqli