mirror of
https://codeberg.org/ThisIsMiseryy/techstore
synced 2026-05-14 14:52:04 +00:00
Aggiunta ruolo utente in sessione al login
This commit is contained in:
@@ -17,18 +17,19 @@
|
|||||||
$email = $_POST['email'];
|
$email = $_POST['email'];
|
||||||
$password = $_POST['password'];
|
$password = $_POST['password'];
|
||||||
|
|
||||||
$sql = "SELECT Name, Password FROM Users WHERE Email = ?";
|
$sql = "SELECT Name, Password, Role FROM Users WHERE Email = ?";
|
||||||
if ($stmt = $conn->prepare($sql)) {
|
if ($stmt = $conn->prepare($sql)) {
|
||||||
$stmt->bind_param("s", $email);
|
$stmt->bind_param("s", $email);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->store_result();
|
$stmt->store_result();
|
||||||
|
|
||||||
if ($stmt->num_rows > 0) {
|
if ($stmt->num_rows > 0) {
|
||||||
$stmt->bind_result($name, $hashed_password);
|
$stmt->bind_result($name, $hashed_password, $role);
|
||||||
$stmt->fetch();
|
$stmt->fetch();
|
||||||
|
|
||||||
if (password_verify($password, $hashed_password)) {
|
if (password_verify($password, $hashed_password)) {
|
||||||
$_SESSION['user'] = $name;
|
$_SESSION['user'] = $name;
|
||||||
|
$_SESSION['role'] = $role;
|
||||||
header('Location: index.php');
|
header('Location: index.php');
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user