Traversing the Phantasmagoria

Explore the odd, depressing, enlightning, joyous parts of humanity.

  • Home
  • About Me

Making A More Secure Login

October 1, 2008

This article is a continuation of my previous article Writing A Simple Login. I came to the realization that our login that we created earlier was not at all secure, so I decided it was time that we tackle the most basic security measures.

So starting off where our last example left off, we’ve had the users enter their username and password and passed it on to our processlogin.php file. After we’ve declared the database connections we’ll want to make a simple function that will check the variables passed through via the post. The function will look something like this.

function make_safe($variable) {
$variable = mysql_real_escape_string(trim($variable));

return $variable;

}

What this function ensures us is that anything malicious the user will try to pass through to our processing page will simply be parsed up and run through the database like normal, thus preventing the user from entering anything malicious into our input fields.

In order to use this function we should call it like so.

$username = make_safe($_POST['username']);
$password = make_safe($_POST['password']);

Thus protecting us from a malicious attack. Hopefully this has helped you out in making your login page more secure with some simple php.

    Posted by condonm
    Filed in PHP
    Tagged: Making login Safe, Malicious, Malicious Attacks, PHP, PHP Functions, PHP Login, Simple PHP Login
    Leave a Comment »
    • Links

      • Casa Basa
      • Chefzilla
      • My Yelp Profile
    • Tags:

      Aliens Aliens The Movie Batman Batman Begins Cheap Movies Cheap Seats Cheap Theatre Comics Disney Dollar Theaters Embeding Emebed Quicktime Family Guy Family Guy Star Wars A New Hope Movie Going to the movies Heath Ledger Heath Ledger's Death How To Add Visual Effects To Ubuntu Legos Lego Trains Linux MMORPG Movies MYSQL PHP PHP 5 PHP Code PHP Functions PHP Login Pirates Pirates of the Caribean MMO Quicktime Quicktime Embeding Scott Kurtzt Simple PHP Login Star Wars St Cloud St Cloud Minnesota Streaming Video The Imaginarium of Doctor Parnassus Ubuntu Ubuntu Cube Ubuntu Visual Effects Visual Effects Youtube
    • Archives

      • October 2008
      • September 2008
      • August 2008
      • March 2008
      • February 2008
      • January 2008
    Theme: Emire by Phu. Blog at WordPress.com.