Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

This question already has an answer here:

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;
    }

?>
share|improve this question

marked as duplicate by Fred -ii-, John Conde php Jul 24 '15 at 2:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
I formatted your code, and now you can see that you're missing a } at the end of your code. – Dave Chen Jul 24 '15 at 1:23
    
btw, using GET with this, is dangerous – Fred -ii- Jul 24 '15 at 1:36
up vote 1 down vote accepted

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;
    }
share|improve this answer
    
Good catch, but that wouldn't cause the end of file error. – Fred -ii- Jul 24 '15 at 1:24
    
yeah i was calculating the brackets lol – Shehary Jul 24 '15 at 1:26
    
sometimes small details, the code does not work, the next time, I will have more attention and thank – Renata P Souza Jul 24 '15 at 1:31
    
@RenataPSouza No problem. – Shehary Jul 24 '15 at 1:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.