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

  • SEARCH
  • Home
  • 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 6682025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:39:29+00:00 2026-05-26T04:39:29+00:00

Basically, Its a login form. I want it to only show the login form,

  • 0

Basically, Its a login form. I want it to only show the login form, when a user session exists (that is when he is logged in). But I am getting the following error

Parse error: syntax error, unexpected $end in C:\xampp\htdocs\zabis\index.php on line 113

Code is given below:

<?php
error_reporting(E_ALL ^ E_NOTICE);
define('INCLUDE_CHECK',true);

require 'connect.php';
require 'functions.php';

session_name('tzLogin');
// Starting the session

session_set_cookie_params(2*7*24*60*60);
// Making the cookie live for 2 weeks

session_start();

if($_SESSION['id'] && !isset($_COOKIE['tzRemember']) && !$_SESSION['rememberMe'])
{
    // If you are logged in, but you don't have the tzRemember cookie (browser restart)
    // and you have not checked the rememberMe checkbox:

    $_SESSION = array();
    session_destroy();

    // Destroy the session
}


if(isset($_GET['logoff']))
{
    $_SESSION = array();
    session_destroy();

    header("Location: demo.php");
    exit;
}

if ($_POST['submit']=='login')
{
  $err = array();

  if(!$_POST['username'] || !$_POST['password'])
                         $err = 'username or password missing!';

  if(!count($err))
  {

    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    $rememberMe = (int)$_POST['rememberMe'];


    $row = mysql_fetch_assoc(mysql_query("SELECT id,usr FROM members WHERE usr='{$username}' AND pass='".md5($password)."'"));

    if($row['usr'])
    {
      $_SESSION['usr']=$row['usr'];
      $_SESSION['id']=$row['id'];
      $_SESSION['rememberMe']=$_POST['rememberMe'];

      //setcookie('tzRemember',$_POST['rememberMe']);

      if($rememberMe=="on")
       setcookie('zsRememberMe',$username, time()+7200);


    }
    else
        $err[] = "wrong username or password!";
  }

  if($err)
   $_SESSION['msg']['login-err'] = implode('<br/>',$err);

   header("Location: index.php");
   exit;
}
else
    die("Please enter a username and password.");


?>





<html>
<body>

<?php
            if(!$_SESSION['id']):
            ?>
<div id="content">
  <h1>Login Form</h1>
  <form id="form1" name="form1" action="doLogin.php" method="post">
    <p>
      <label for="username">Username: </label>
      <input type="text" name="username" id="username" />
    </p>
    <p>
      <label for="password">Password: </label>
      <input type="password" name="password" id="password" />
    </p>
    <p/>
    <input type="checkbox" name="rememberMe"> Remember me
    <p>
      <input type="submit" id="login" name="login" />
    </p>
  </form>
    <div id="message"></div>
</div>
</body>
</html>
  • 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-26T04:39:29+00:00Added an answer on May 26, 2026 at 4:39 am

    Change

    <?php
            if(!$_SESSION['id']):
            ?>
    <div id="content">
    <h1>Login Form</h1>
    <form id="form1" name="form1" action="doLogin.php" method="post">
    <p>
      <label for="username">Username: </label>
      <input type="text" name="username" id="username" />
    </p>
    <p>
      <label for="password">Password: </label>
      <input type="password" name="password" id="password" />
    </p>
    <p/>
    <input type="checkbox" name="rememberMe"> Remember me
    <p>
      <input type="submit" id="login" name="login" />
    </p>
    </form>
    <div id="message"></div>
    </div>
    </body>
    </html>
    

    to

    <?php
            if(!$_SESSION['id']):
            ?>
    <div id="content">
    <h1>Login Form</h1>
    <form id="form1" name="form1" action="doLogin.php" method="post">
    <p>
      <label for="username">Username: </label>
      <input type="text" name="username" id="username" />
    </p>
    <p>
      <label for="password">Password: </label>
      <input type="password" name="password" id="password" />
    </p>
    <p/>
    <input type="checkbox" name="rememberMe"> Remember me
    <p>
      <input type="submit" id="login" name="login" />
    </p>
    </form>
    <div id="message"></div>
    </div>
    <?php endif; ?>
    </body>
    </html>
    

    note that <?php endif; ?>. You have forgotten to close last if statement

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

Sidebar

Related Questions

I have a simple login form, username and password. Basically, When a user is
I have a webpage that requires login. Once a user has logged in I
I have a view where the user can change some settings, its basically a
Basically, I just want to know if its possible to use Nhibernate to migrate
I have a class that is its own activity that basically i use to
I added a regex validator but its not showing anything on the page, basically
How do I determine that mdworker (Spotlight) has completed its first scan? I'm basically
Its maybe not the best solution in most cases, but i want a table
I have a JSF page that is basically a create form. The form consists
Basically I want to upload image and Video file with an html form. Image

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.