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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:16:28+00:00 2026-05-18T20:16:28+00:00

HI, this is my first time doing this. I’ve read The definitive guide to

  • 0

HI, this is my first time doing this. I’ve read The definitive guide to form-based website authentication and http://en.wikibooks.org/wiki/PHP_Programming/User_login_systems, but I still have doubts as to whether I’m doing this correctly. Note: I’m doing this to learn, so please don’t suggest a framework and php pear auth or any other related class. I just want some guidance on what I can do to improve this.

I don’t need CIA style security, just something basic for a login site:

Anyway, this is how my login works:

  1. Wait for user to press Login

    if (isset($_POST[‘action’]) && $_POST[‘action’] == ‘Login’)

  2. Does form token match token stored in session? If not die.

  3. Use php filters to validate string in username and password
  4. Hash the password (sha256) (with salt, I use the same salt for every password)
  5. Use mysqli to check for username and hashed password (LIMIT 1 in SQL).
  6. If no match is found show an error — otherwise set the session (hashed with sha256)

At the bottom of all this I place the following, this is the line I am most worried about:
My thinking is that, if the session is not set, then show the login form and exit.

 if
 (!isset($_SESSION['authenticated'])) {
     require_once 'html/login_form.html';  
     exit();   }
 // secret stuff goes here

The full code can be found here. It is still incomplete.

I will also attempt to implement this: How can I throttle user login attempts in PHP.

I am grateful for any feedback.

  • 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-18T20:16:28+00:00Added an answer on May 18, 2026 at 8:16 pm

    This is a pretty open question as there are so many areas to pick apart. However, for average security, I would at least recommend changing the following.

    Number 2: Don’t use the same salt. This means if the salt is compromised so are all the hashed values. I would recommend one way encrypting the password. Users would rather reset it than know it could be reasonably decrypted.

    Number 5: Don’t forget about SQL Injection. Far more important than LIMIT 1. Check out mysql_real_escape_string()

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

Sidebar

Related Questions

HI, this is my first time doing this. I've read The definitive guide to
This is my first time doing VB :-) I've inherited a web site, which
This is my first time doing this sort of project so apologies if the
I am doing some uploading stuff in iphone this time. This is absolutely first
this is my first time doing a gallery of videos using ASP.NET, I believe
I'm building a fairly large website in Django, and it's my first time doing
I have never collected DOB before. This is the first time i am doing
This is my first time attempting to call an ASP.NET page method from jQuery.
This is my first time using joomla. I don't know if I'm using the
This is my first time with Web services. I have to develop web services

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.