Php script code For Login system
Php script code For Login system.Php script code to build login system ,users will have to register themselves and than using username and password they will be able to enter into your website.
php login script system |
This phpscript code will return to the homepage after the user has registered .this phpscript code has three files.
login.php
register.php
lastmember.php
?Login.php Start?
<?php
//session_start();
// set your infomation.
$dbhost='localhost';
$dbusername='root';
$dbuserpass='root';
$dbname='root';
if (isset($_COOKIE['user'])) {
echo "Welcome $_COOKIE[user]";
}else{
//connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
if ($_POST['username']) {
//did they supply a password and username
$username=$_POST['username'];
$password=$_POST['password'];
if ($password==NULL) {
echo "A password was not supplied";
}else{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['password'] != $password) {
echo "The supplied login is incorrect";
}else{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
setcookie("user", "$username", time()+3600);
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=membersarea.php\">";
}
}
}
?>
<form action='login.php' method='POST'>
<table style='border:1px solid #000000;'>
<tr>
<td align='right'>
Username: <input type='text' size='15' maxlength='25' name='username'>
</td>
</tr>
<tr>
<td align='right'>
Password: <input type='password' size='15' maxlength='25' name='password'>
</td>
</tr>
<tr>
<td align='center'>
<input type="submit" value="Login">
</td>
</tr>
<tr>
<td align='center'>
<a href='register.php'>Register Here</a>
</td>
</tr>
</table>
</form>
<?
};
?>
?End Of Login.php?
?Register.php start.?
<center>
<?php
// set your infomation.
$dbhost='localhost';
$dbusername='root';
$dbuserpass='root';
$dbname='root';
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die("Cannot select database");
//Are they just getting here or submitting their info?
if (isset($_POST["username"])) {
$username = $_POST["username"];
$password = $_POST["password"];
$cpassword = $_POST["cpassword"];
$email = $_POST["email"];
//Was a field left blank?
if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL) {
echo "A field was left blank.";
}else{
//Do the passwords match?
if($password!=$cpassword) {
echo "Passwords do not match";
}else{
//Has the username or email been used?
$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);
$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");
$email_exist = mysql_num_rows($checkemail);
if ($email_existɬ|$username_existɬ) {
echo "The username or email is already in use";
}else{
//Everything seems good, lets insert.
$query = "INSERT INTO users (username, password, email) VALUES('$username','$password','$email')";
mysql_query($query) or die(mysql_error());
echo "The user $username has been successfully registered.";
}
}
}
}
?>
<h1>Register</h1>
<form action="register.php" method="POST">
<table style="border:1px solid #000000;">
<tr>
<td align="right">
Username: <input type="text" size="15" maxlength="25" name="username">
</td>
</tr>
<tr>
<td align="right">
Password: <input type="password" size="15" maxlength="25" name="password">
</td>
</tr>
<tr>
<td align="right">
Confirm Password: <input type="password" size="15" maxlength="25" name="cpassword">
</td>
</tr>
<tr>
<td align="right">
Email: <input type="text" size="15" maxlength="25" name="email">
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="Register">
</td>
</tr>
<tr>
<td align="center">
<a href="login.php">Login Here</a>
</td>
</tr>
</table>
</form>
</center>
?End Of Register.php?
?Lastmember.php start?
// set your infomation.
$dbhost='localhost';
$dbusername='root';
$dbuserpass='root';
$dbname='root';
//connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
$row1 = mysql_query("SELECT * FROM users ORDER BY uid DESC LIMIT 1") or die(mysql_error());
echo "$row1";
while($row=mysql_fetch_array($row1))
{
echo "<h2>$row[username]</h2>";
}
?>
?End of lastmember.php?
To check to see if someone is logged in use.
<?
if (isset($_COOKIE['user'])) {
echo "You are logged in: $_COOKIE['user'] Enjoy.";
} else{
echo "You are not logged in. <a href='register.php'>Register here</a>";
?>
<br><font face="Tahoma"><a target="_blank" href="http://www.blogspotinfo.com/"><span style="font-size: 8pt; text-decoration: none">PHP Free Code</span></a></font>
<?php
//session_start();
// set your infomation.
$dbhost='localhost';
$dbusername='root';
$dbuserpass='root';
$dbname='root';
if (isset($_COOKIE['user'])) {
echo "Welcome $_COOKIE[user]";
}else{
//connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
if ($_POST['username']) {
//did they supply a password and username
$username=$_POST['username'];
$password=$_POST['password'];
if ($password==NULL) {
echo "A password was not supplied";
}else{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['password'] != $password) {
echo "The supplied login is incorrect";
}else{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
setcookie("user", "$username", time()+3600);
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=membersarea.php\">";
}
}
}
?>
<form action='login.php' method='POST'>
<table style='border:1px solid #000000;'>
<tr>
<td align='right'>
Username: <input type='text' size='15' maxlength='25' name='username'>
</td>
</tr>
<tr>
<td align='right'>
Password: <input type='password' size='15' maxlength='25' name='password'>
</td>
</tr>
<tr>
<td align='center'>
<input type="submit" value="Login">
</td>
</tr>
<tr>
<td align='center'>
<a href='register.php'>Register Here</a>
</td>
</tr>
</table>
</form>
<?
};
?>
?End Of Login.php?
?Register.php start.?
<center>
<?php
// set your infomation.
$dbhost='localhost';
$dbusername='root';
$dbuserpass='root';
$dbname='root';
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die("Cannot select database");
//Are they just getting here or submitting their info?
if (isset($_POST["username"])) {
$username = $_POST["username"];
$password = $_POST["password"];
$cpassword = $_POST["cpassword"];
$email = $_POST["email"];
//Was a field left blank?
if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL) {
echo "A field was left blank.";
}else{
//Do the passwords match?
if($password!=$cpassword) {
echo "Passwords do not match";
}else{
//Has the username or email been used?
$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);
$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");
$email_exist = mysql_num_rows($checkemail);
if ($email_existɬ|$username_existɬ) {
echo "The username or email is already in use";
}else{
//Everything seems good, lets insert.
$query = "INSERT INTO users (username, password, email) VALUES('$username','$password','$email')";
mysql_query($query) or die(mysql_error());
echo "The user $username has been successfully registered.";
}
}
}
}
?>
<h1>Register</h1>
<form action="register.php" method="POST">
<table style="border:1px solid #000000;">
<tr>
<td align="right">
Username: <input type="text" size="15" maxlength="25" name="username">
</td>
</tr>
<tr>
<td align="right">
Password: <input type="password" size="15" maxlength="25" name="password">
</td>
</tr>
<tr>
<td align="right">
Confirm Password: <input type="password" size="15" maxlength="25" name="cpassword">
</td>
</tr>
<tr>
<td align="right">
Email: <input type="text" size="15" maxlength="25" name="email">
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="Register">
</td>
</tr>
<tr>
<td align="center">
<a href="login.php">Login Here</a>
</td>
</tr>
</table>
</form>
</center>
?End Of Register.php?
?Lastmember.php start?
// set your infomation.
$dbhost='localhost';
$dbusername='root';
$dbuserpass='root';
$dbname='root';
//connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
$row1 = mysql_query("SELECT * FROM users ORDER BY uid DESC LIMIT 1") or die(mysql_error());
echo "$row1";
while($row=mysql_fetch_array($row1))
{
echo "<h2>$row[username]</h2>";
}
?>
?End of lastmember.php?
To check to see if someone is logged in use.
<?
if (isset($_COOKIE['user'])) {
echo "You are logged in: $_COOKIE['user'] Enjoy.";
} else{
echo "You are not logged in. <a href='register.php'>Register here</a>";
?>
<br><font face="Tahoma"><a target="_blank" href="http://www.blogspotinfo.com/"><span style="font-size: 8pt; text-decoration: none">PHP Free Code</span></a></font>
Php code script For online user
Php code script For online user
Blogspotinfo.com provides you the phpscript code to display how many users are online in your website at current...
Php script code For Login system
Php script code to build login system ,users will have to register themselves and than using username and...
Php Script Code For Forum
Blogspotinfo.com provides you php code script to build your own Forum in your website.you will get answer of your...
Free Php code script to Ban IP Address
PHP FREE CODE SCRIPT TO BAN IP ADDRESS AT BLOGSPOTINFO.COM
Free Php script code:Contact us Form For Website
Blogspotinfo.com provides you the php script code to create Contact us form for your...
0 comments :