mardi 26 février 2019

Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\MyLogin\includes\login.inc.php on line 17 [duplicate]

This question already has an answer here:

i have created a login form and on that form i have signed up as a user and when i try logging in i get - Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\MyLogin\includes\login.inc.php on line 17, i have tried removing and adding ; or } but this doesn't seem to be fixing the problem. I have entered the code below for the login file.

<?php

session_start();

if (isset($_POST['submit'])) {

  include 'dbh.inc.php';

$uid = mysqli_real_escape_string($conn, $_POST['uid']);
$pwd = mysqli_real_escape_string($conn, $_POST['pwd']);

// Error handlers
// Check if the inputs are empty
if (empty($uid) || empty($pwd)); {
  header("Location: ../index.php?login=empty");
  exit();
}else {
  $sql = "SELECT * FROM users WHERE user_uid = '$uid'";
  $result = mysqli_query($conn, $sql);
  $resultCheck = mysqli_num_rows($result);
  if ($resultCheck < 1) {
    header("Location: ../index.php?login=error");
    exit();
  } else {
    if ($row = mysqli_fetch_assoc($result)) {
      // Dehashing the password for the user
      $hashedPwdCheck = password_verify($pwd, $row['user_pwd']);
      if ($hashedPwdCheck == false){
        header("Location: ../index.php?login=error");
        exit();
      }elseif ($hashedPwdCheck == true) {
        //Log in the user into the website here
        $_SESSION['u_id'] =$row['user_id'];
        $_SESSION['u_firstname'] =$row['user_firstname'];
        $_SESSION['u_lastname'] =$row['user_lastname'];
        $_SESSION['user_email'] =$row['user_email'];
        $_SESSION['u_uid'] =$row['user_uid'];
        header("Location: ../index.php?login=success");
        exit();
      }
    }
  }
} else {
  header("Location: ../index.php?login=error");
  exit();

}




Aucun commentaire:

Enregistrer un commentaire