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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:12:13+00:00 2026-05-30T08:12:13+00:00

Is this login system secure ? if ($_POST[$submit]){ $user = $_POST[$user]; $pass = $_POST[$pass];

  • 0

Is this login system secure ?

    if ($_POST[$submit]){

$user = $_POST[$user];
$pass = $_POST[$pass];

if ($user && $pass){ //if user and pass is enterered

        require("vars.php"); //require MySQL conection settings
        mysql_connect($auth_mysql_server, $auth_mysql_user, $auth_mysql_pass); //connect to MySQL
        mysql_select_db($auth_mysql_db); // select MySQL database

        $pass = md5($pass); // hash password

        $query = mysql_query("SELECT * FROM $auth_mysql_table WHERE user='$user'"); // run query
        $numrows = mysql_num_rows($query);

        if ($numrows == 1){ //check if user exists
            $row = mysql_fetch_assoc ($query);
            $dbid = $row[$auth_mysql_id_row];
                $dbuser = $row[$auth_mysql_user_row];
                $dbpass = $row[$auth_mysql_pass_row];

                if ($pass == $dbpass){ // if password is equal to the one in the database start session
                    session_start();
                    //set session information
                    $_SESSION['user'] = $dbuser;

                    header("Location:$auth_loggedin"); // goto logged in page

                }
                else return (3);
        }
        else return (2);

        mysql_close(); // close MySql connection
    }
    else return (1);}

If not how could i make it secure ?

I hashed the password but i know md5 can be decrypted however sha1 can be too.Also is themysql_close() needed ?

  • 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-30T08:12:14+00:00Added an answer on May 30, 2026 at 8:12 am

    no it is not secure. you are opening yourself to sql-injection attacks. imagine what would happen, if somebody entered this into your user-input-field (which goes into the $_POST[$user])

    a'; drop table user; select '1'='1
    

    this would result in an sql statement like this:

    SELECT * FROM $auth_mysql_table WHERE user='a'; drop table user; select '1'='1'
    

    which you would execute against your database. that’s bad!

    you need to sanitize your input. read this: http://php.net/manual/en/security.database.sql-injection.php

    edit: relevant

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

Sidebar

Related Questions

I would like to make a simple user login/registration system using PHP and mysql.
For a login system in php would this be a suitable outline of how
I'm making an Ajax login system and i wonder if this is secure Post
I'm working on a web based system (PHP & MySQL) that has users who
I'm in the process of trying to make a secure PHP based login system
I'm thinking about building a login system for Ruby on Rails, much like this
I am trying to build openid login system for my website. To do this
Consider this T-SQL: CREATE USER my_test_user WITHOUT LOGIN; SELECT USER_NAME(), USER, SUSER_SNAME(),SYSTEM_USER, suser_name(); EXECUTE
I've been making this login form in C# and I wanted to 'submit' all
Can anyone see anything wrong with this login script: public function login($username, $pass, $remember)

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.