Now we will make a log-out page
Code for log-out page
<?php
require
'core.inc.php';
session_destroy();
header('Location:
'.$http_referer);
?>
Paste this code and make the name of the file as “logout.php”.
Now we will make again a vital page which is for
Registration
Pest this code
<?php
if(isset($_POST['username'])
&& isset($_POST['password'])) {
$username =
$_POST['username'];
$password =
$_POST['password'];
$password_hash =
md5($password);
if(!empty($username)
&& !empty($password)) {
$query = "SELECT
`id` FROM `users` WHERE `username`='$username' AND
`password`='$password_hash'";
if($query_run =
mysql_query($query)) {
$query_num_rows =
mysql_num_rows($query_run);
if($query_num_rows==0)
{
echo "invalid
username/password";
} else
if($query_num_rows==1){
echo $user_id =
mysql_result($query_run, 0, 'id');
$_SESSION['user_id']=$user_id;
@header("Location:
index.php");
}
}
} else{
echo "you must
supply data";
}
}
?>
<form
action="<?php echo $current_file; ?>"
method="post">
Username: <input
type="text" name="username"> Password: <input
type="password" name="password">
<input
type="submit" value="Log in">
</form>
Save the file as “loginform.inc.php”
Finally make a file name as “register_success.php”
And Paste
successfully
registered.
You have made
registration page.
No comments:
Post a Comment