My VIDEO courses:

How to create secure PHP script login form page using session video tutorial

In this tutorial I will teach you to create secure login process using PHP session object variable and database to store the login information of our members.

This is very useful if you have a members are on your website.

This login process is very common and I am sure you will use it in your projects.

Here is the code I used:


Login:

This should be inside the login_go.php(the target page of the login form)

$user=$_GET['user'];
$password=$_GET['password'];
$result_login = mysql_query(“SELECT * from XXX WHERE user=’$user’ and password=’$password’”,$db);
if ($myrow_login = mysql_fetch_array($result_login))
$_SESSION['user']=$user;

Logout:

unset($_SESSION['user']);
session_destroy();

Be sure to include session_start(); at the beginning of each page where sessions are used.

I strongly advice to ready my post about protecting your website form sql injection attacks before creating such a login form.

Fell free to contact me if any question.

Related Posts

  1. Video tutorial: How to create PHP Shopping cart using SESSION object variables
  2. Video tutorial: Form validation in Macromedia Dreamweaver
  3. How to create custom made 404 error file not found page on your website video tutorial
  4. Video tutorial: How to create CSS button rollover effect menu web design tutorial
  5. JavaScript tutorial validate form: Textboxes, select , check box – components and EMAIL validation
1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 5.00 out of 5)
Loading ... Loading ...

Comments (4)

taswa March 4th, 2010 at 12:39    

hi this is rele a nice tutorial so would u mind to upload how to upload a profile picture by the members??

thanks

Alex Flom March 4th, 2010 at 12:54    

PHP Form June 28th, 2010 at 17:42    

Thanks, I thought it was more difficult

freedelta August 2nd, 2010 at 16:48    

Hi,
Thank you for this script
I needed a little login script like this

Leave a reply

Name *

Mail *

Website

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word