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 7497267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:00:37+00:00 2026-05-29T19:00:37+00:00

I am currently working on a site and i’m making a login system. I

  • 0

I am currently working on a site and i’m making a login system. I am using sessions to keep track of login status. The pages involving login until now are shown below:
(I change pages defining post variables in the url, like this: site.domain.com/?home)

index.php

/* CONNECTION TO CHECK LOGIN STATUS */
<?php
if (isset($_GET["sair"])){
    session_start();
    session_destroy();
}
if (isset($_SESSION["user"]) && isset($_GET["entrar"])){
    mysql_connect("localhost","dbusr","password") or die("Can't connect to DB");
    mysql_select_db("mydb") or die("Can't select DB");
    $userinfo = $_SESSION["uinfo"];
}
?> /* START OF THE PAGE, RANDOM UNIMPORTANT HTML */
<?php if (!isset($_SESSION["user"])) { ?> /*NOT LOGGED IN...*/
<form id="loginform" method="post" action="scripts/checklogin.php">
<h2>Login</h2>
<?php if (isset($_GET["falha"])) { echo "<span class='erro'>Nome ou senha incorretos</span>"; }?> /*IF LOGIN ERROR*/
<input type="text" name="user" autofocus placeholder="Apelido"/><br />
<input type="password" name="pass" placeholder="Senha"/><br /> /*LOGIN FORM*/
<input type="submit" value="Entrar"/>
</form>
<?php
} else { /*LOGGED IN...*/
if ($userinfo["sexo"]=="0"){ /*GENDER*/
echo "Bem-vindo, ".$userinfo["nome"];
} else {
echo "Bem-vinda, ".$userinfo["nome"];
}?>
<?php }?>

scripts/checklogin.php

<?php

mysql_connect("localhost","dbusr","password") or die("Can't connect to DB");
mysql_select_db("mydb") or die("Can't select DB");
$user = mysql_real_escape_string(stripslashes($_POST["user"]));
$pass = md5(mysql_real_escape_string(stripslashes($_POST["pass"])));
$result = mysql_query("SELECT * FROM users WHERE apelido = \"".$user."\" AND senha = \"".$pass."\"");
if (count($result)==1) {
    session_start();
    $_SESSION["user"] = $user;
    $_SESSION["pass"] = $pass;
    while ($row = mysql_fetch_assoc($result)) {
        $_SESSION["uinfo"] = $row;
    }
    header("location:../?entrar");
} else {
    header("location:../?falha");
}
?>

But when i go to the page and enter my info, it still doesn’tshow the logged in part. Also, when i input a incorrect login, it does not show me the text over the login form (the <span>)

  • 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-29T19:00:39+00:00Added an answer on May 29, 2026 at 7:00 pm

    You need to add session_start() in index.php before checking $_SESSION["user"].

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

Sidebar

Related Questions

Some background I'm currently working on a mobile site so I keep switching user
I'm currently working on an ASP.NET web-site. In one of my pages, I had
I am very new to Ruby and I am currently working on site-scraping using
I am currently working on a zend framework site using an ACL. The ACL
I have a site that I am currently working on in ASP.NET 2.0 using
I'm currently working on an ASP.NET 4.0 site using a project-less solution. By default
I'm currently working on a new site. I'm just a few pages deep and
I am currently working on Drupal site using Joomlart template JD Fashion.I have inserted
Currently working on a site built in Django and i'm getting an issue when
Im currently working on a site that you can upload large files.. on local

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.