
1. Index.php
2. Config.php
3. Daftar.php
First of all to be done, of course, is to create a database first. Make a database with the name? reglog?. Then create a table with the name? members?. Then enter following fields:
? Id? type = bigint (20)
? name? type = varchar (50)
? email? type = varchar (50)
? password? type = varchar (8)
If so, enter the following script:
This is to connect your database :
Config.php
<? php
$ host = "localhost";
$ user = "root";
$ pass = "";
$ db = "reglog";
$ table = "members";
$ the connect = mysql_connect ($ host, $ user, $ pass) or die ("Failed to conn");
$ pilih_db = mysql_select_db ($ db) or die ("Database does not exist");
$ cookie_nama = $ _COOKIE ['name'];
?>
<? php
$ host = "localhost";
$ user = "root";
$ pass = "";
$ db = "reglog";
$ table = "members";
$ the connect = mysql_connect ($ host, $ user, $ pass) or die ("Failed to conn");
$ pilih_db = mysql_select_db ($ db) or die ("Database does not exist");
$ cookie_nama = $ _COOKIE ['name'];
?>
Index.php
<? Php
include ("config.php");
?>
<? Php
if ($ _GET ['register'])
{
include ("daftar.php");
exit;
}
?>
<? Php
if ($ _GET ['register2'])
{
include ("daftar2.php");
exit;
}
?>
<? Php
if ($ _GET ['login'])
{
include ("login.php");
exit;
}
?>
<style type="text/css">
<! -
. Style1 {color: # FFFFFF}
. Style2 {color: # 0000FF}
->
</ Style>
<p>
<? Php
if ($ _GET ['logout'])
{
print "You have successfully logged out! <p>";
}
<? Php
include ("config.php");
?>
<? Php
if ($ _GET ['register'])
{
include ("daftar.php");
exit;
}
?>
<? Php
if ($ _GET ['register2'])
{
include ("daftar2.php");
exit;
}
?>
<? Php
if ($ _GET ['login'])
{
include ("login.php");
exit;
}
?>
<style type="text/css">
<! -
. Style1 {color: # FFFFFF}
. Style2 {color: # 0000FF}
->
</ Style>
<p>
<? Php
if ($ _GET ['logout'])
{
print "You have successfully logged out! <p>";
}
> Welcome
<? php
$ cookie_name = $ _COOKIE ['name'];
print "$ cookie_name";
?> [<a href="logout.php" class="style2"> Logout </ a>] </ p>
<p> Click <a
href = "index.php? register = enter% 20name, email, and% 20password% 20 to% 20 list"
class = "style2"> here </ a> to register </ p>
name="form1" <form method="POST" action="index.php?login=success">
<table width="400" border="0">
<tr bgcolor="#999999">
<td colspan="2"> <span class="style1"> Login </ span> </ td>
</ tr>
<tr bgcolor="#CCCCCC">
<td> User: </ td>
<td> <input type="text" name="user" id="user"> </ td>
</ tr>
<tr bgcolor="#CCCCCC">
<td> Password: </ td>
<td> <input type="password" name="password" id="password"> </ td>
</ tr>
<tr>
<td colspan="2"> </ td>
</ tr>
<tr>
<td colspan="2"> <input type = "submit" name = "Submit" value = "Login!"
style = "background-color: # CCCCCC"> </ td>
</ tr>
</ table>
</ form>
<p> </ p>
<? php mysql_close ($ connect);?>
<? php
$ cookie_name = $ _COOKIE ['name'];
print "$ cookie_name";
?> [<a href="logout.php" class="style2"> Logout </ a>] </ p>
<p> Click <a
href = "index.php? register = enter% 20name, email, and% 20password% 20 to% 20 list"
class = "style2"> here </ a> to register </ p>
name="form1" <form method="POST" action="index.php?login=success">
<table width="400" border="0">
<tr bgcolor="#999999">
<td colspan="2"> <span class="style1"> Login </ span> </ td>
</ tr>
<tr bgcolor="#CCCCCC">
<td> User: </ td>
<td> <input type="text" name="user" id="user"> </ td>
</ tr>
<tr bgcolor="#CCCCCC">
<td> Password: </ td>
<td> <input type="password" name="password" id="password"> </ td>
</ tr>
<tr>
<td colspan="2"> </ td>
</ tr>
<tr>
<td colspan="2"> <input type = "submit" name = "Submit" value = "Login!"
style = "background-color: # CCCCCC"> </ td>
</ tr>
</ table>
</ form>
<p> </ p>
<? php mysql_close ($ connect);?>
Daftar.php
<style type="text/css">
<! -
. style3 {font-size: 24px}
->
</ style>
name="form1" <form method="POST" action="index.php?register2=success">
<table width="400" border="0">
<tr>
<td colspan="2"> <span class="style3"> Register </ span> </ td>
</ tr>
<tr>
<td> Name: </ td>
<td> <input type="text" name="name" id="name"> </ td>
</ tr>
<tr>
<td> Email: </ td>
<td> <input type="text" name="email" id="email"> </ td>
</ tr>
<tr>
<td> Password: </ td>
<td> <input type="password" name="password" id="password"> </ td>
</ tr>
<tr>
<td> Confirm Password: </ td>
<td> <input type="password" name="c_password" id="c_password"> </ td>
</ tr>
<tr>
<td colspan="2"> </ td>
</ tr>
<tr>
<td colspan="2"> <input type="submit" name="Submit" value="Register"> </ td>
</ tr>
</ table>
</ form>
<? php mysql_close ($ connect);?>
<style type="text/css">
<! -
. style3 {font-size: 24px}
->
</ style>
name="form1" <form method="POST" action="index.php?register2=success">
<table width="400" border="0">
<tr>
<td colspan="2"> <span class="style3"> Register </ span> </ td>
</ tr>
<tr>
<td> Name: </ td>
<td> <input type="text" name="name" id="name"> </ td>
</ tr>
<tr>
<td> Email: </ td>
<td> <input type="text" name="email" id="email"> </ td>
</ tr>
<tr>
<td> Password: </ td>
<td> <input type="password" name="password" id="password"> </ td>
</ tr>
<tr>
<td> Confirm Password: </ td>
<td> <input type="password" name="c_password" id="c_password"> </ td>
</ tr>
<tr>
<td colspan="2"> </ td>
</ tr>
<tr>
<td colspan="2"> <input type="submit" name="Submit" value="Register"> </ td>
</ tr>
</ table>
</ form>
<? php mysql_close ($ connect);?>
4 comments on Create Register | Login | Logout Script With PHP :
that look like something missing on that code, the input password never compare with the save password in database to autentication.
For savely, use hash function to compare the value of the saved and input password.
Thanks.
tyang @ codeprogram.co.cc
I hope This Blog to be your reference
Great post. Was wondering if you could have the files as a downloadable file.
Thanks anyway for the tutorial.
Your script dont work but nice post
Post a Comment and Don't Spam!
Dont Spam please