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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:30:35+00:00 2026-05-26T18:30:35+00:00

As part of my web app. This is some code I am considering (I’m

  • 0

As part of my web app. This is some code I am considering (I’m not the best of PHP programmers but I programming my own app for a project):

// Start session
session_start();
// Is the user already logged in?
if (isset($_SESSION['username'])) {
    header('Location: members-only-page.php');
}

I want to know, if my login structure is like this, is this secure.

  • http://site.com/
  • https://site.com/login.php
  • https://site.com/login-action.php (MySQL login check, with md5 password check)
  • http://site.com/cp/members-only-page.php

I am using MD5(); but I am not entirely happy with the whole $_session[“user”]=”1″ approach that scripts use; surely the likes of vBulletin wouldn’t do this?

Appreciate a reply. I’ve not even touched on the idea of this being Ajax ha!

UPDATE – Psuedo code of my approach. Everything on SSL.

// vars
login string post
password string post

// validation aside from ajax now
login string is empty
redirect to login form with error
password string is empty
redirect to login form with error

// mysql
escape strings
clean html strings

mysql connect external mysql server
if login string is user
    if password md5 match with database md5
        session logged in
    else
        session failed password invalid
        redirect to login form user/pass error
    end if
else
    session failed username invalid
    redirect to login form user/pass error
end if

if file called direct
    redirect 404
    alert_admin function type hacking attempt login page
end if
  • 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-26T18:30:36+00:00Added an answer on May 26, 2026 at 6:30 pm
    1. mysql_real_escape_string() does not safeguard you from all forms of SQL Injection, or other types of attack for that matter. You should use a system in which incorperates code to guard against many safeguards individually, an example of such I use on my testing server (not strong enough for production):

      function sanitize($str)
      {
        $str = trim($str);
      
        if (get_magic_quotes_gpc())
          $str = stripslashes($str);
      
        return htmlentities(mysql_real_escape_string($str));
      }
      

    Please read the accepted answer for this question to see why any way you filter user input is never full-proof.

    —

    As far as information about securing user logins, please consider the following tips:

    1. Avoid user input whenever possible, and if impossible; sanitize their input.
    2. Do not use only md5 for securing user passwords. It is easy to decrypt.
      • Consider using a password salt, unique to each individual user.
    3. Keep your own passwords both long, and diverse.
      • Optionally extend these as suggestions to your users’ passwords. Example:
        • Must be at least six characters in length.
        • Must consist of a mixed case of characters.
        • Must contain at least one number.
        • (Secure) Must contain at least one symbol.

    Rationale and statistics about password strength:

    I, (with a nVidia NVS 3100M mobile graphics card), can crack or “brute force” an MD5 or SHA1 hash at a speed of 56,900,000 passwords per second. This means I can complete all passwords of lengths 1 – 6 characters, with a full (a-zA-Z0-9 + symbols) character set; in less than four minutes. Imagine what someone with a decent computer (even a gaming one), or a server could do.

    The way to safe against this is to salt your passwords. Depending on how you salt your passwords, the “attacker” would need to try many different means of decrypting before they would be able to guess any of your user’s passwords. If your password was not salted, they could brute-force it in the way I have described above.

    Read more about PHP Session Security:

    PHP Security Guide – Session Security

    PHP Session Security (StackOverflow)

    Notes on Session Security (SitePoint)

    Also Worth Nothing:

    You need to decide what your website needs to be secured against. If your website is hosted on a shared server or shared hosting (whether it be a VPN, VPS, or some sort of semi-dedicated solution) you will always be at risk of other malicious users on the system having access to your PHP files, and by extension; your MySQL database. Even on a dedicated server, without proper internal network security you are just as screwed.

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

Sidebar

Related Questions

In my (PHP) web app, I have a part of my site that keeps
I saw some other similar questions on this topic here but they were not
I have a python daemon running as a part of my web app/ How
As part of a larger web-app (using CakePHP), I'm putting together a simple blog
I have an ASP.NET 2.0 web app and part of the structure still has
Part of my app caches web pages for offline viewing. To do that, I
I am using spring web mvc for my app's UI part.. By using following
We have an Android app and a Web Service. We want to download part
My Sharepoint 2007 web part executes code to start a K2 workflow process. The
I want to test some new functionality which is part of an internal web

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.