Jump to content

Parse Error ? Driving me crazy ... Help Please


PHPFAN10

Recommended Posts

Hi,

 

The code below is not yet finished but i left it today and went to do something came back and forgot where i left off half way through code. It says Parse error: syntax error, unexpected $end in C:\wamp\www\member\login.php on line 305. Not on line 305 thou as that is the last line. I think i have missed a parentheses or curly bracelet. My eyes are watering now i have looked over and over. Please someone help.

 

Like i say it's not yet finished or formatted to it's best but hopefully one of you people on here can help me :)

 

Thanks

 

<?php
//ob_start();

// Include config.php
require_once("".$_SERVER['DOCUMENT_ROOT']."/lib/config.php");

// top.inc.php
require_once($top_inc);
?>

<!-- Meta start -->
<title><?php echo $websitename; ?> - Member Login</title>
<meta name="description" content="<?php echo $websitename; ?> - Member Login" />
<meta name="keywords" content="<?php echo $websitename; ?>, login, signup, register, sign in, signin, sign up" />
<!-- Meta end -->

<?php
// main.inc.php
require_once($main_inc);
?>

<!-- CONTENT HERE -->


<?php
    // Check if form has been submitted
    if(isset($_POST['submit']) && $_SERVER['REQUEST_METHOD'] == 'POST'){

        # Connect to databse
        sql_con();

        # Get form data and cleanse
        $username = msqls(trim($_POST['username']));
        $password = msqls(trim($_POST['password']));
        $ip = msqls($_SERVER['REMOTE_ADDR']);

        # Validate form data
        if (utfstrlen($username) < 1) {
            $error .= "Please enter your username <br />";
        }
        if (utfstrlen($username) > 0 && !preg_match(constant("USERNAME_REGEX"), $username)) {
            $error .= "Username invalid format <br />";
        }
        if (utfstrlen($password) < 1) {
            $error .= "Please enter your password <br />";
        }
        if (utfstrlen($password) > 0 && !preg_match(constant('PASSWORD_REGEX'), $password)) {
            $error .= "Password invalid format<br />";
        }

        # If error founds display them
        if(isset($error)){
        $SiteErrorMessages = "$error";
        SiteErrorMessages();
        } # else no errors found continue processing
        else {
            # Check if user has activated there account
            $status_check = mysql_query("SELECT username FROM ".constant("TBL_USERS")."
            WHERE username = '$username' AND status = '".constant("USER_STATUS_VERIFY")."' LIMIT 1");

            # Check if user has requested account to be deleted
            $delete_check = mysql_query("SELECT username FROM ".constant("TBL_USERS")."
            WHERE username = '$username' AND status = '".constant("USER_STATUS_DELETE")."'
            AND password = '".sha1($password)."' LIMIT 1");

            # Check if user has been suspended
            $username_status_check = mysql_query("SELECT username, suspended_note FROM ".constant("TBL_USERS")."
            WHERE username = '$username' AND status = '".constant("USER_STATUS_SUSPENDED")."'
            AND password = '".sha1($password)."' LIMIT 1");

            # Check above queries if error occurs notify user
            if(!$delete_check || !$status_check || !$username_status_check){
            echo '<h1>Oops something went wrong </h1>';

            $SiteErrorMessages =
            "Something went wrong while processing your request. Please try again later.
            <br /> $websitename has been notified of this error and will investigate further.";

            SiteErrorMessages();

            # This variable will be passed to the site_errors_email_notification function
            $site_error_email_message_notification = "User Login Failure <br />
            A user tried to login but the verify, suspended or delete query check failed.
            <br /><br /><b>".mysql_error()."</b><br /><br />
            There details are below. <br /><br />
            Username: <b>$username</b> <br />";
            # This function will pass the above variable (message) to the admin error notify function
            # to send admin an email to notify them of an error
            site_errors_email_notification();

            include("$footer_inc");
            exit;
            } # else queries ok continue processing
            else {
                 # Check delete query
                 if (mysql_num_rows($delete_check) == 1) {
                 echo '<h1>Account Deletion In Process</h1>';
                 echo "<p><b>Sorry, you cannot login to your account as you requested your account to be deleted.</b>
                      <b>Your account is queued for deletion from the $websitename database and will be deleted within 24 hours.</b></p>";

                 echo "<p><b>$websitename sent you a confirmation email when you requested your account to be removed.</b>
                      <b>If you did not make this request via your account please <a href=\"../contactus.php\">contact us</a> immediately.</b></p>";

                 echo "<p><b>Please note that it may not be possible to recover your account as the process is automated.</b></p>";
                 header( 'refresh: 60; url=$websiteaddress' );
                 include ("$footer_inc");
                 exit;
                 }
                 # Check status query
                 elseif (mysql_num_rows($status_check) == 1) {
                 echo "<h1>Account Activation Required</h1>";
                 echo "<p><b>You must activate your account via email before you can login.</b></p>";
                 header( 'refresh: 10; url=resendactivationemail.php' );
                 include ("$footer_inc");
                 exit;
                }
                 # Check username status query
                 elseif (mysql_num_rows($username_status_check) == 1) {
                 $row = mysql_fetch_row($username_status_check);
                 echo "<h1>Account Suspended</h1>";
                 echo "<p>Dear <b>" . $row[0] . "</b>, <br />
                      Your account has been suspended. The administrator has left the
                      following message:</p>";

                 $no_suspended_note =
                 "The administrator has not left a message. <br />
                 If you feel your account has been suspended in error please contact $websitename <a href=\"/contactus.php\">here</a>.";

                 if (utfstrlen($row[1]) < 1) {
                    $SiteWarningMessages = "$no_suspended_note";
                    SiteWarningMessages();
                    include ("$footer_inc");
                    exit;
                 } else {
                    $SiteWarningMessages = " . $row[1] . ";
                    SiteWarningMessages();
                    echo '<p>If you feel your account has been suspended in error please contact ' . $websitename . ' <a href="/contactus.php">here</a>.<br />
                    <b>Please include your username when contacting ' . $websitename . '.</b></p>';
                    include ("$footer_inc");
                    exit;
                }
            } # else user must be ok to login so continue ...
            else {
                # Login Query
                $query = mysql_query("SELECT id, admin, username, first_name, last_name, email, last_visited,
                date_time, websiteurl, msn, aim, yim, twitter, gender
                FROM ".constant("TBL_USERS")." WHERE username = '$username' AND
                password = '".sha1($password)."' LIMIT 1");

                # Check login query
                if(!$query){
                    echo '<h1>Oops something went wrong</h1>';

                    $SiteErrorMessages =
                    "Something went wrong while trying to log you in. Please try again later.
                    <br /> $websitename has been notified of this error and will investigate further.";

                    SiteErrorMessages();

                    // This variable will be passed to the site_errors_email_notification function
                    $site_error_email_message_notification = "User Login Failure <br />
                    A user tried to login but the Login Verification Check failed.
                    <br /><br /><b>".mysql_error()."</b><br /><br />
                    There details are below. <br /><br />
                    Username: <b>$username</b> <br />";
                    # This function will pass the above variable (message) to the admin error notify function
                    # to send admin an email to notify them of an error
                    site_errors_email_notification();

                    include("$footer_inc");
                    exit;
            } # else login query ok so continue
            else {
                # Validate credentials against DB
                if (mysql_num_rows($query) == 1) {
                    $found_user = mysql_fetch_array($query);

                    # Tell them they are being logged in
                    echo '<h1>Your now being logged in ...</h1>';
                    $SiteSuccessMessages = '<a href=\"/member/cp.php\">Click here if you
                    do not automatically redirect</a>';

                    SiteSuccessMessages();

                    # User logged in succesfully reset failed login number to 0
                    $failed_login_reset = mysql_query("UPDATE ".constant("TBL_USERS")." SET
                    `failed_login_count` = '0', `ip` = '" . $ip . "'
                    WHERE `username` = '" . $username . "' LIMIT 1");

                    # check failed login query
                    if(!$failed_login_reset){
                    // This variable will be passed to the site_errors_email_notification function
                    $site_error_email_message_notification = "User Login Failure <br />
                    A user logged in but the failed login reset counter query failed.
                    <br /><br /><b>".mysql_error()."</b><br /><br />
                    There details are below. <br /><br />
                    Username: <b>$username</b> <br />";
                    # This function will pass the above variable (message) to the admin error notify function
                    # to send admin an email to notify them of an error
                    site_errors_email_notification();
                    }

                    # Store all member data into session to use for later on other areas of the website
                    $_SESSION['username'] = $found_user['username'];
                    $_SESSION['id'] = $found_user['id'];
                    $_SESSION['admin'] = $found_user['admin'];
                    $_SESSION['last_visited'] = date('l dS F Y, g:i:s A', $found_user['last_visited']);
                    $_SESSION['first_name'] = $found_user['first_name'];
                    $_SESSION['last_name'] = $found_user['last_name'];
                    $_SESSION['email'] = $found_user['email'];
                    $_SESSION['websiteurl'] = $found_user['websiteurl'];
                    $_SESSION['msn'] = $found_user['msn'];
                    $_SESSION['aim'] = $found_user['aim'];
                    $_SESSION['yim'] = $found_user['yim'];
                    $_SESSION['twitter'] = $found_user['twitter'];
                    $_SESSION['gender'] = $found_user['gender'];
                    $_SESSION['date_time'] = date('l dS F Y, g:i:s A', $found_user['date_time']);
                    $_SESSION['date_time_for_profile'] = $found_user['date_time'];
                    $_SESSION['time'] = time();
                    if (isset($_GET['redirect'])) {
                        redirect($websiteaddress . $_GET['redirect'], 2);
                    } else {
                        redirect("cp.php", "0");
                    }
                    include ("$footer_inc");
                    exit;
            } # else login details invalid
            else {
                # Login Details Invalid Error
                echo 'Login Details Invalid';

                # If user fails 3 logins lock there account
                $login_failure_query = mysql_query("SELECT username, email, failed_login_count,
                status FROM ".constant("TBL_USERS")." WHERE username = '$username' AND
                status = '".constant("USER_STATUS_ACTIVATED")."' LIMIT 1");

                # Check if query ok
                if(!$login_failure_query){

                    # This variable will be passed to the site_errors_email_notification function
                    $site_error_email_message_notification = "Login Failure Query <br />
                    A user tried to login but the Login Failure Query Check failed.
                    <br /><br /><b>".mysql_error()."</b><br /><br />
                    There details are below. <br /><br />
                    Username: <b>$username</b> <br />";
                    # This function will pass the above variable (message) to the admin error notify function
                    # to send admin an email to notify them of an error
                    site_errors_email_notification();

                    include("$footer_inc");
                    exit;

                } # else login_failure_query ok so continue ...
                else {
                    # Check
                    if (mysql_num_rows($login_failure_query) == 1) {
                        # Fetch user row
                        $row = mysql_fetch_row($login_failure_query);
                        # Store data in variables
                        $username_ = $row[0];
                        $email = $row[1];
                        # Increment failed login row by 1 on each failed login
                        $login_count = $row[2] + 1;
                        # Update failed_login_count row each time login fails
                        $update_login_number = mysql_query("UPDATE ".constant("TBL_USERS")." SET `failed_login_count`
                        = '" . $login_count . "' WHERE `username` = '" . $username . "'");
                        # Fetch total failed logins
                        $login_count_total = $row[2];
                }
            }
        }
    }
?>

<h1>Login</h1>

<form action="login.php<?php if (isset($_GET['redirect']))
{ echo "?redirect=" . $_GET['redirect']; } ?>" method="post"
id="frmcontact">

    <label for="username">Username</label>
    <input type="text" name="username" id="username"
    value="<?php if (isset($username)) { echo $username; } ?>" class="textboxcontact" />

    <label for="password">Password</label>
    <input type="password" name="password" id="password" class="textboxcontact" />

    <label for="submit"> </label>
    <input type="submit" name="submit" id="submit" value="Sign In" class="submitcontact" />

</form>

<!-- CONTENT FINISH -->

<?php
// footer.inc.php
require_once($footer_inc);

//ob_end_flush();
?>

Link to comment
Share on other sites

You seem to be missing 4 closing curly braces.

 

really? can you please edit and re-post code as i cannot see where :o lol. My eyes are literally watering with glaring at the screen to long trying to find them. I really need to ask a question on debugging to help me out in future. I use NetBeans but never delved into the debugging features.

 

Thanks

 

 

Link to comment
Share on other sites

i suggest that you indent your code consistently, and then the oddities should become more apparent. 'matching curlies' is just about the simplest problem you could have.

 

I know will take that advice on board. When you say 'matching curlies' is just about the simplest problem you could have. do you mean there are problems with my script that i should fix apart from these missing curlie bracelets ? or was it a figure of speech ?

 

Reason why code is not indented properly is because i used to use Dreamweaver but then switched to NetBeans and NetBeans seemed to not keep the formatting of the code as it was when in dreamweaver which made it loose the formatting. I highlight everything then go to source then format in NetBeans but it still does not indent it like it was when in dreamweaver, but when i start from scratch in NetBeans the indenting is fab.

 

I still cannot see them thou  :shrug:

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.

Guest
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.