Simple Login in php my sql.


Carrierride.com

Learn to create a simple login system with php + mysql script, this tutorial is easy to follow, teach you step by step.

In this tutorial, we create 3 php files for testing our code.
1. index.php (loginform)
2. config.php(mysql connectivity)
3. home.php(after login page redirects)

4. logout.php

STEP1: Create Database named “ravindra” and make a new table named login

CREATE TABLE `login` (
`id` int(4) NOT NULL auto_increment,
`email_id` varchar(65) NOT NULL default ”,
`password` varchar(65) NOT NULL default ”,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;


— Dumping data for table `members`

INSERT INTO `members` VALUES (1, ‘choudhary’, ‘admin’);

STEP2: Create file config.php for database Connectivity

<?php
session_start();
$hostname=”localhost”;
$user=”root”;
$password=””;

mysql_connect($hostname, $user, $password) or die(mysql_error());
mysql_select_db(“ravindra”) or die (mysql_error());

?>

you can change hostname, user and password according your system

STEP3: Create file index.php having login form

<?php
include ‘config.php’;
if(isset($_SESSION[‘username’]))
{
header(“location:home.php”);
}
if(isset($_POST[‘submit’]))

View original post 106 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s