-4

New to php. I am getting the error

"Parse error: syntax error, unexpected 'mailuid' (T_STRING) in /includes/login.inc.php on line 7"

when trying to follow the mmtuts tutorial on creating a php login page.

Tried checking for missing semi-colons and quotes.

'

<?php

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

require 'dbh.inc.php";

$mailuid = $_POST['mailuid'];
$password = $_POST['pwd'];

if (empty($mailuid) || empty($password)) {
    header("Location: ../index.php?error=emptyfields");
    exit();
}

else {
    $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();
    }

    else {
        mysqli_stmt_bind_param($stmt, "ss", $mailuid, $mailuid);
        mysqli_stmt_execute($stmt);
        $result = mysqli_stmt_get_result($stmt);

        if ($row = mysqli_fetch_assoc($result)) {
            $pwdCheck = password_verify($password, $row['pwdUsers']);

            if (pwdCheck == false) {
                header("Location: ../index.php?error=wronginfo");
                exit();
            }

            else if ($pwdCheck == true) {
                session_start();
                $_SESSION[userId] = $row['idUsers'];
                $_SESSION[userUid] = $row['uidUsers'];

                header("Location: ../index.php?login=success");
                exit();
            }

            else {
                header("Location: ../index.php?error=wronginfo");
                exit();
            }
        }

        else {
            header("Location: ../index.php?error=nouser");
            exit();
        }
    }

}
}

else {
    header("Location: ../index.php");
    exit();
}

'

devpro
  • 16,184
  • 3
  • 27
  • 38

1 Answers1

-1

The error is simple, you you mismatched quotes at Line 7 where you require dbh.inc.php

Replace require 'dbh.inc.php"; with require 'dbh.inc.php';

Manav
  • 1,357
  • 10
  • 17
  • questions like this shoudln't be answered by closed - if you want to help, I'd say it better to leave a comment rather than give an answer. These questions 9/10 get deleted anyway – treyBake Jul 04 '19 at 11:45