Hi guys, basically, I've been stuck on this problem FOREVER!

When I open the webpage, I get this error.

Parse error: syntax error, unexpected '&&' (T_BOOLEAN_AND) in C:\Program Files (x86)\EasyPHP-12.1\www\Creative Landscapes\functions.php on line 83

Line 83:

else if (isset($_POST['submit'] && empty($_POST['username']) or empty($_POST['password']){

Missing closing )

else if (isset($_POST['submit']) && empty($_POST['username']) or empty($_POST['password']){
Member Avatar for LastMitch

Parse error: syntax error, unexpected '&&' (T_BOOLEAN_AND) in C:\Program Files (x86)\EasyPHP-12.1\www\Creative Landscapes\functions.php on line 83

I don't understand your logic?

What you doing here:

else if (isset($_POST['submit'] && empty($_POST['username']) or empty($_POST['password']){

Try this:

if(isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
} else if (!empty($username) && !empty($password)){

Unfortunately, neither of your solutions worked. I'm sorry. How about this. This is the whole if statement.

if(!isLoggedIn()) {
        // add header function if prefer
        echo "<h2 align=\"center\">Member Login</h2>";
        if(!isset($_POST['submit'])) {
            echo "<form method=\"POST\" action=\"".$_SERVER['PHP_SELF']."\">
            <center>
            <table>
              <tr>
                <td>Username:</td>
                <td><input type=\"text\" name=\"username\"></td>
              </tr>
              <tr>
                <td>Password:</td>
                <td><input type=\"password\" name=\"password\"></td>
              </tr>
              <tr>
                <td colspan=2 align=center>
                <input type=\"submit\" name=\"submit\" value=\"submit\"></td>
              </tr>
            </table>";
            // add footer function here
            die();

        } else if (isset($_POST['submit']) && empty($_POST['username']) or empty($_POST['password']){
            // add header function here
            echo "<center><font color=\"red\" align=\"center\"><b>Please enter a username/password to login</b></font></center>";
            // add footer function here
            die();
        } else if(isset($_POST['submit']) && !empty($_POST['username']) && !empty($_POST['password'])) {

            // Validate their login
            $result = @mysql_query("SELECT * FROM $users_table WHERE username='".$_POST['username']."' AND password='".md5($_POST['password'])."'");
            if(mysql_num_rows($result) < 1) {
                //not in database
                // add header function here
                echo "<center><font color=\"red\" align=\"center\"><b>Invalid username/password combination.  Please try again.</b></font></center>";
                // add footer function here
                die();
            } else {
                //entered correct, create session and refresh page
                $_SESSION[$sess_name] = $_POST['username'];
                header("Location: $_SERVER[PHP_SELF]");
            }

        }

    }

}
Member Avatar for LastMitch

Unfortunately, neither of your solutions worked. I'm sorry. How about this. This is the whole if statement.

What is the error are you getting now?

All I did was tell you where you error was coming from in that one little line of code. It wasn't going to remove all of your problems if there were more.

The form validation you putting this through is a bit much. You only need to check if the form has been submitted once, and you only need to check if the fields are empty once. You also have an extra closing bracket at the bottom "}"

Pixelsoul: I changed the coding to what you gave me and I'm receiving a new error.(Same Line)

Parse error: syntax error, unexpected '{' in C:\Program Files (x86)\EasyPHP-12.1\www\Creative Landscapes\functions.php on line 83

You're missing another closing bracket again..

} else if (isset($_POST['submit']) && empty($_POST['username']) or empty($_POST['password'])){

I'm also quite sure that your call to the header function will not work like that either. You would have to make it like this.

header("Location: ".$_SERVER[PHP_SELF]);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.