Show DevBest Simple Login Script

Status
Not open for further replies.

Super

New Member
Feb 8, 2011
33
1
Download This file for it to be more simple. You may have to edit the database information:
You must be registered for see images attach

To start off create the files:
index.php (Login Page Where the Form Will Be)
checklogin.php (Checking the username and password)
login_plus.php (If Checklogin.php Worked.)

To start off create:
The table "users" in the database "usersystem"
Next create all of these files and Create file logout.php

Next to create the table use this code:
CREATE TABLE `users` (
`id` int(4) NOT NULL auto_increment,
`username` varchar(32) NOT NULL default '',
`password` varchar(24) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;

--
-- Dumping data for table `users`
--

INSERT INTO `members` VALUES (1, 'name', 'password');

Now you'll want to create the "Index.php" With this code:
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="4" cellspacing="2" bgcolor="#FFFFFF">
<tr>
<td width="78">Name</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="password" id="mypassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</form>
</tr>
</table>

Checklogin.php will now have to be coded:
<?php
$host="localhost";
$username=""; // The name you set
$password=""; // The Pass you've set
$db_name="usersystem"; // Database name
$tbl_name="users"; // Table name

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

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

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

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

$count=mysql_num_rows($result);

if($count==1){
session_register("myusername");
session_register("mypassword");
header("location:login_plus.php");
}
else {
echo "Incorrect Username Or Password";
}
?>

Login_plus.php time. Just place this code in every place of which you want users to log in.:
<?
session_start();
if(!session_is_registered(myusername)){
header("location:index.php");
}
?>

This is just a Simple Logout Script:
<?
session_start();
session_destroy();
?>
(Be aware you will need to have this set as a custom page and it will just destroy the session of which "login_plus" started.)

Noob Friendly. If I helped +Like it.
 
Status
Not open for further replies.

Users who are viewing this thread

Top