AlfieWebDevTips Homefor new and experienced developers
[Home Home] [Web Development Web Development ] [Code Generators Code Generators ] [Resources Resources ] [Contact Us Contact ] |WebDevTips Privacy Privacy |
Print This Page

You are here : Home - Web Development - PHP - Password Protect - Login

Password Protect - Login



copy and save as index.php
<html> 
<head> 
    <title>Login Page</title> 
</head> 
<body bgcolor="white"> 
<table width="400" align="center"> 
<tr> 
    <th valign=top> private area </th> 
</tr> 
<tr> 
    <td> 
<p>This is a private area. </p> 
<p>Please log in below if you have access to this area </p> 
<? 
//if no cookie is set then display the form 
if(!isset($_COOKIE["this_cookie"])){ 
echo '<div align="center"><form action="validate.php" method="post">'; 
echo 'username : <input type="text" name="username"><br><br>'; 
echo 'password : <input type="password" name="password"><br><br>'; 
echo '<input type="submit" value="login"></form></div>'; 
}else{ 
echo "You are already logged in.  <a href=\"1.php\">Continue</a>"; 

?>
 
    </td> 
</tr> 
</table> 
</body> 
</html>

Nothing special about the form except that is written using php. This line
if(!isset($_COOKIE["this_cookie"])){ basically means, if the cookie isn't set then write the form or else write a link text.

Next we'll look at the validation script.


overview
the theory
the login
validation
a protected page
the logout
If you like our script, please rate it!







Google
 

[back to top of page]   

[labelled with icra -  - this link will open in a new window] [RSS Content]

[Copyright © WebDevTips]