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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:26:22+00:00 2026-05-19T02:26:22+00:00

Okay, so I want to make a simple login page. I’ve created a register

  • 0

Okay, so I want to make a simple login page. I’ve created a register page successfully, but i can’t get the login thing down.

login.php:

<?php

session_start();

include("mainmenu.php");

$usrname = mysql_real_escape_string($_POST['usrname']);
$password = md5($_POST['password']);

$con = mysql_connect("localhost", "root", "g00dfor@boy");
 if(!$con){
  die(mysql_error());
}

mysql_select_db("users", $con) or die(mysql_error());

$login = "SELECT * FROM `users` WHERE (usrname = '$usrname' AND password = '$password')";
$result = mysql_query($login);

 if(mysql_num_rows($result) == 1 {

    $_SESSION = true;
    header('Location: indexlogin.php');
 }

   else {
echo = "Wrong username or password." ;
}


?>

indexlogin.php just echoes “Login successful.” What am I doing wrong?
Oh, and just FYI- my database is “users” and my table is “data”.

  • 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-19T02:26:23+00:00Added an answer on May 19, 2026 at 2:26 am
    <?php
    
    session_start();
    
    include("mainmenu.php");
    
    $usrname = mysql_real_escape_string($_POST['usrname']);
    $password = md5($_POST['password']);
    
    $con = mysql_connect("localhost", "root", "g00dfor@boy");
    if (!$con) {
        die(mysql_error());
    }
    
    mysql_select_db("users", $con) or die(mysql_error());
    
    $login = "SELECT * FROM `users` WHERE (usrname = '$usrname' AND password = '$password')";
    $result = mysql_query($login);
    
    if (mysql_num_rows($result) == 1) {
        $_SESSION['logged_in'] = true;
        header('Location: indexlogin.php');
        exit;
    } else {
        echo "Wrong username or password.";
    }
    
    ?>
    
    • I added mysql_real_escape_string() to prevent SQL injection.
      No, I didn’t because you already had it.
    • I cleaned up the formatting of the code a bit.
    • I changed $_SESSION = true; (which doesn’t make sense) into $_SESSION['logged_in'] = true;. Then, in indexlogin.php you can do something like if ($_SESSION['logged_in']) { echo $secret; }
    • I fixed echo = "Wrong username or password."; to echo "Wrong username or password.";
    • I added a closing bracket near mysql_num_rows($result) == 1.

    You said:

    my database is “users” and my table is
    “data”.

    If this is correct, you will need to change SELECT * FROM users to SELECT * FROM data.

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

Sidebar

Related Questions

Okay, so I want to make a polling site but it doesn't work like
Okay, I know this is probably dead simple, but I can't seem to find
Okay so I want to make an application that launches other applications. However, the
Okay, so I want to have a generic method that can read data from
okay so this is probably a soft pitch question for sombody, but I want
Okay this is very hard to explain, but i want to add padding to
Okay, so I'm trying to make a very simple program in ruby and I
the code below is working, but I want to make sure it's correct .
Okay, this is a simple question, but I'd like some oppinions on the correct
Hello guys I'm using C and GTK+ 2 I want to make a simple

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.