Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4064334
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:50:33+00:00 2026-05-20T15:50:33+00:00

I’m making a login script and I keep getting this error Parse error: syntax

  • 0

I’m making a login script and I keep getting this error

Parse error: syntax error, unexpected
T_ELSE in
/Users/Sites/website/login.php on
line 59

and here is my code:

    <?php

        if(isset($_POST['submitted'])) {

            if(!empty($_POST['email'])) {
                $email = mysql_real_escape_string($_POST['email']);
            } else {
                $email = false;
                echo "<p class='error'>You forgot to enter your email address.</p>";
            }


            if(!empty($_POST['password'])) {
                $password = mysql_real_escape_string($_POST['password']);
            } else {
                $email = false;
                echo "<p class='error'>You forgot to enter your password.</p>";
            }

            if($email && $password){
                $query = "SELECT * FROM `users` WHERE email='$email' AND pass=SHA1('$password') AND active='0'";
                $result= mysql_query ($query, $link) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error($link));
                while ($row = mysql_fetch_array($result)){
                    $id = $row['id'];
                    $bizid = $row['biz_id'];
                    $firstname = $row['first_name'];
                    $lastname = $row['last_name'];
                    $email = $row['email'];
                    $pass = $row['pass'];
                    $date_joined = $row['registration_date'];
                    $address = $row['address'];
                    $phone = $row['phone'];
                    $_SESSION['auth']=1;
                    $_SESSION['id'] = $id;
                    $_SESSION['bizid'] = $bizid;
                    $_SESSION['firstname'] = $firstname;
                    $_SESSION['lastname'] = $lastname;
                    $_SESSION['email'] = $email;
                    $_SESSION['date_joined'] = $date_joined;
                    $_SESSION['address'] = $address;
                    $_SESSION['phone'] = $phone;

                    header("Location: profile.php");
                    exit();
                }   else{
                        echo"<p class='error'>Your email or password was incorrect. Please try again.</p>";
                    }

                }

            }
            mysql_close($link);

        ?>

        <form method='post' action='./login.php'>
        <label>Email Address:</label><br/><input type='text' class='normal' style='border:1px #999 solid;' name='email' />
        <br/><br/><label>Password:</label><br/><input type='password' class='normal' style='border:1px #999 solid;' name='password' />
        <input type='submit' class='normalbutton' value='Login' />
        <p><br/><a href='forgotpassword.php'>Forgot Your Password?</a></p>
        <p><br/><a href='signup.php'>Don't have an Account? Sign Up</a></p>
        <input type='hidden' name='submitted' value='TRUE' />
        </form>

And help would be greatly appreciated. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:50:34+00:00Added an answer on May 20, 2026 at 3:50 pm

    This is a fixed up version of your code.

    if (isset($_POST['submitted']))
    {
        $errors   = array();
        $required = array('email', 'password');
    
        foreach($required as $field)
        {
            if(empty($_POST[$field]))
            {
                $errors[$field] = 'You forgot to enter the '. $field .' field.';
            }
            else {
                $required[$field] = = mysql_real_escape_string($_POST[$field]);
            }
        }
    
        if(count($errors) == 0)
        {
            $query = "SELECT * FROM `users` WHERE email='$email' AND password=SHA1('$password') AND active='0' LIMIT 1";
            $result= mysql_query ($query, $link) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error($link));
    
            if(mysql_num_rows($result) > 0)
            {
                while ($row = mysql_fetch_array($result))
                {
                    $id                         = $row['id'];
                    $bizid                      = $row['biz_id'];
                    $firstname                  = $row['first_name'];
                    $lastname                   = $row['last_name'];
                    $email                      = $row['email'];
                    $pass                       = $row['pass'];
                    $date_joined                = $row['registration_date'];
                    $address                    = $row['address'];
                    $phone                      = $row['phone'];
    
                    $_SESSION['auth']           = 1;
                    $_SESSION['id']             = $id;
                    $_SESSION['bizid']          = $bizid;
                    $_SESSION['firstname']      = $firstname;
                    $_SESSION['lastname']       = $lastname;
                    $_SESSION['email']          = $email;
                    $_SESSION['date_joined']    = $date_joined;
                    $_SESSION['address']        = $address;
                    $_SESSION['phone']          = $phone;
    
                    header("Location: profile.php");
                    exit();
                }
            }
            else{
                echo '<p class="error">Your email and password was not entered correctly!</p>'
            }
        }
        else{
            foreach($errors as $error)
            {
                echo '<p class="error">'. $error .'</p>';
            }
        }
    }
    
    mysql_close($link);
    
    ?>
    <form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post'>
        <p>
            <label>Email Address:</label>
            <input type='text' class='normal' style='border:1px #999 solid;' name='email' />
        </p>
        <p>
            <label>Password:</label>
            <input type='password' class='normal' style='border:1px #999 solid;' name='password' />
        </p>
        <p>
            <input type='submit' name="submitted" class='normalbutton' value='Login' />
            <a href='signup.php'>Don't have an Account? Sign Up</a>
        </p>
        <p>
            <a href='forgotpassword.php'>Forgot Your Password?</a>
        </p>
    </form>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.