All PHP Tutorials
Ad Management
Counter
Email System
Forum and Guestbook
File Upload
Image Manipulation
Login / Members / Password
Pagination
Encode Script
Refresh / Redirection
Miscellaneous
All MySQL Tutorials
Create, Manage Database using phpMyAdmin
Connect to Database
Insert Data
Select Data
Edit Database
Update Database
Delete Database
Order Results



Home > PHP Tutorials
Encrypting Password using md5() function
Encrypting Password using md5() function
Using md5(); function to make your login system more secure 
 
  Syntax

$password="123456";

md5($password);

Use md5(); to encrypts password to make it more secure


  Overview
Look at these two databases, it's the same person and same info, the first one we don't encrypt his password but the second one we encrypted his password

 

when you encryte "john856" using this code, you'll see this result
"ad65d5054042fda44ba3fdc97cee80c6" This is not a random result, everytime you encrypt the same password you will get the same result.

$password="john856";
$encrypt_password=md5($password);

echo $encrypt_password;


  Example - Login


This is an example Login with encrypted password but don't forget to encrypt password and insert into database in sign up process.

// username and password sent from form

$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];

// encrypt password
$encrypted_mypassword=md5($mypassword);

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$encrypted_mypassword'";
$result=mysql_query($sql);

You can learn to create login system here

Random
 
PHP Counter script tutorial
Creates your own counter script. Using a basic knowledge of php + mysql script and keeps your visitors number to database for analysis. 
 
 
   
Hosted by Hostgator
© PHPeasystep.com 2005-2007