Jump to content

Need Help


Recommended Posts

Parse error: syntax error, unexpected ';' in on line 7

I been looking for a while but I think I have been over looking it. I been doing this all day so. I can not find the problem.



if (isset($_POST['login'])) {
  require 'dbh.inc.php';
  $logUid = $_POST['logUid'];
  $logPwd = $_POST['logPwd'];
  if (empty($logUid) || (empty($logPwd)) {
    header("Location: ../login.php?error=emptyfields");
    else {
      $sql = "SELECT * FROM users WHERE uidUsers=?;";
      $stmt = mysqli_stmt_init($conn);
      if (!mysqli_stmt_prepare($stmt, $sql)) {
        header("Location: ../login.php?error=sqli");
      } else {
          mysqli_stmt_bind_param($stmt, "s", $logUid);
          $result = mysqli_stmt_get_result($stmt);
          if ($row = mysqli_fetch_assoc($result)) {
              $pwdCheck = password_verify($logPwd, $row['pwdUsers']);
              if ($pwdCheck == false) {
                header("Location: ../login.php?error=wrong");
              else if($pwdCheck == true) {
                $_SESSION['username'] = $row['uidUser'];
                $_SESSION['email'] = $row['emailUsers'];
                header("Location: ../index.php?login");
              }  else {
                  header("Location: ../login.php?error=usernotfound");
  header("Location: ../login.php");



Link to comment
Share on other sites

actually, you have an unnecessary ( which then doesn't have a matching ), both on line #6.

as to the posted logic. you have far too much code, mainly because your form and for processing code are not on the same page and you are using the mysqli database extension. if you put the form processing code on the same page as the form, stop copying variables to other variables, store validation errors in an array, switch to the much simpler php PDO database extension, and use exceptions to handle database errors, about half of the code you have now will go away.

you also have a logic mistake later in the code. your 'usernotfound' condition is part of the password check logic (which can only be either true of false, there's no point in the final else statement), not as part of the fetch check logic. this type of mistake can be avoided by properly indenting your code and also by eliminating unnecessary code (see the above paragraph.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.