Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php declare(strict_types=1);
- if (!isset($_POST['login-submit'])) {
- header("Location: ../index.php");
- exit();
- }
- require 'dbh.inc.php';
- $mailuid = $_POST['mailuid'] ?? null;
- $password = $_POST['pwd'] ?? null;
- if (empty($mailuid) || empty($password)) {
- header("Location: ../index.php?error=emptyfields");
- exit();
- }
- $sql = "SELECT * FROM users WHERE uidUsers=? OR emailUsers=?;";
- $stmt = mysqli_stmt_init($conn);
- if (!mysqli_stmt_prepare($stmt, $sql)) {
- header("Location: ../index.php?error=sqlerror");
- exit();
- }
- mysqli_stmt_bind_param($stmt, "ss", $mailuid, $mailuid);
- mysqli_stmt_execute($stmt);
- $result = mysqli_stmt_get_result($stmt);
- if (!$row = mysqli_fetch_assoc($result)) {
- header("Location: ../index.php?error=nouser");
- exit();
- }
- $pwdCheck = password_verify($password, $row['pwdUsers']);
- if ($pwdCheck == false) {
- header("Location: ../index.php?error=wrongpwd");
- exit();
- }
- session_start();
- $_SESSION['userId'] = $row['idUsers'];
- $_SESSION['userUid'] = $row['uidUsers'];
- header("Location: ../index.php?login=success");
- exit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement