0

with these code instructions in php (autent.php), I thinks everything is good but when I made login, and I receive the error:

Parse error: syntax error, unexpected end of file autent.php in line 30

So is the last line when finish php instruction " ?> "

<?php
include "connect.php";
/*connect to database with oracle 11g*/

$email = $_GET['username'];
$passw = $_GET['password'];

$query   = "SELECT * login WHERE user_email = '$email' AND user_pass= '$passw'";
$sid     = oci_parse($conn, $query);
$result  = oci_execute($sid);
$dbarray = oci_fetch_array($sid);


if (($email != "") && ($passw != "")) {
    if ($dbarray["user_email"] != $email) {
        echo "<script> alert('Wrong Email!'); history.back() </script>";
        exit;
    }
    if ($dbarray["user_pass"] != $passw) {
        echo "<script> alert('Wrong Password!'); history.back() </script>";
        exit;
    }
    if (($dbarray["user_email"] == $email) && ($dbarray["user_pass"] == $passw)) {
        session_start();
        $_SESSION["user_email"] = $email;
        $_SESSION["user_pass"]  = $passw;
        switch ($dbarray["type_user_id"]) {
            case 1:
                header("Location: admin.php");
                break;
            default:
                echo "<script> alert('ERROR:'); history.back() </script>";
                exit;
                break;
        }
    } else {
        echo "<script> alert('ERROR:'); history.back() </script>";
        exit;
    }

?>
Dave Chen
  • 10,887
  • 8
  • 39
  • 67
Renata P Souza
  • 255
  • 3
  • 20

1 Answers1

1

you are missing FROM here

$query = "SELECT * login WHERE user_email = '$email' AND user_pass= '$passw'";

right one is

$query = "SELECT * FROM login WHERE user_email = '$email' AND user_pass= '$passw'";

also you are missing closing bracket here

    }
} else {
    echo "<script> alert('ERROR:'); history.back() </script>";
    exit;
}

?>

so correct is

if (($email != "") && ($passw != "")) {
        if ($dbarray["user_email"] != $email) {
            echo "<script> alert('Wrong Email!'); history.back() </script>";
            exit;
        }
        if ($dbarray["user_pass"] != $passw) {
            echo "<script> alert('Wrong Password!'); history.back() </script>";
            exit;
        }
        if (($dbarray["user_email"] == $email) && ($dbarray["user_pass"] == $passw)) {
            session_start();
            $_SESSION["user_email"] = $email;
            $_SESSION["user_pass"]  = $passw;
            switch ($dbarray["type_user_id"]) {
                case 1:
                    header("Location: admin.php");
                    break;
                default:
                    echo "<script> alert('ERROR:'); history.back() </script>";
                    exit;
                    break;
            }
        }
} else {
        echo "<script> alert('ERROR:'); history.back() </script>";
        exit;
    }
Shehary
  • 9,926
  • 10
  • 42
  • 71