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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:12:41+00:00 2026-05-11T04:12:41+00:00

if (isset($_POST[‘login’])) { $query = mysql_query(" SELECT id FROM users WHERE username = ‘".mysql_real_escape_string($_POST[‘username’])."’

  • 0
if (isset($_POST['login'])) { $query = mysql_query("           SELECT id FROM users            WHERE username = '".mysql_real_escape_string($_POST['username'])."'        AND password = '".mysql_real_escape_string($_POST['password'])."' ");  /* wrong login information? output a message and terminate the script */ if (!mysql_num_rows($query)){ header("Location: error.php"); exit(); }  /* set session with unique index */ $_SESSION['id'] = mysql_result($query, 0, 'id'); mysql_query("UPDATE users SET last_login = NOW(), last_ip = '".$_SERVER['REMOTE_ADDR']."' WHERE id = '{$_SESSION['id']}'"); header("Location: success.php"); exit; }  /* destroy session */ if (isset($_GET['logout'])){ mysql_query("UPDATE users SET online = '0' WHERE id = '{$_SESSION['id']}'"); session_unset(); session_destroy(); header("Location: index.php"); exit; } 

It works, it does send me to success PHP on right info but this is what I’m trying to do:

if (!$_SESSION['id']) {      <form method="post" action="./"><p>      Username: <br />      <input type="text" name="username" size="22" maxlength="30" />      <br />      Password: <br />      <input type="password" name="password" size="22" maxlength="20" />      <br />      <input class="button" type="submit" name="login" value="Login" />      </form>     } else { echo "Logged in"; }  

It doesn’t show "Logged in", I have printed $_SESSION[‘id’] but nothing. It’s all in index.php. What can be the problem? And don’t worry about no hash, going to fix that later

  • 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. 2026-05-11T04:12:41+00:00Added an answer on May 11, 2026 at 4:12 am

    Have you definitely called session_start?

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

Sidebar

Related Questions

elseif(isset($_POST['submit'])) { // Look for their user $lookuser = mysql_query(SELECT * FROM `users` WHERE
topic.php $id = isset($_GET['id']) ? intval($_GET['id']) : 0; $query = mysql_query(SELECT * FROM topics
if(isset($_POST['uname'])) { $query = SELECT * FROM user_info; $res = $mysqli->query($query); $num = $res->num_rows;
<?php if(isset($_POST[user_name])) { $user_name=$_POST[user_name]; include(include/conn.php); $sql_check = mysql_query(select userid from `vector`.`signup` where userid='.$user_name.') or
This is my registration.php include(config.php); if(isset($_POST['submit'],$_POST['fullname'],$_POST['username'], $_POST['password'], $_POST['email'], $_POST['role'])) { $submit=$_POST['submit']; $date=date(y-m-d); $fullname =
Will this work? $username = mysql_real_escape_string(isset($_POST['username'])) ? $_POST['username'] : ''; I know the ternary
I'm using this php script $error = false; if(isset($_POST['login'])){ $username = preg_replace('/[^A-Za-z]/', '', $_POST['username']);
<?php session_start(); if(isset($_POST['username']) && ($_POST['password'])) { $con=mysql_connect(localhost,root,); if(!$con) { die('Could Not Connect:'.mysql_error()); } mysql_select_db(tcs,$con);
<?php session_start(); include(connect.php); $timeout = 60 * 30; $fingerprint = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']); if(isset($_POST['userName']))
Hello I have something like this: if(isset($_POST['btnProm'])){ $idads = mysql_real_escape_string($_POST['idAds']); require_once(adPromFrm.php); } When a

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.