phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP Login:Creating Login Form Use phpSecureSite

Tag: login, security, phpsecuresite   Category: PHP Security, PHP Classes
post: 08 Jan 2008 read: 2,084


PHP Login System Tutorial: Now, we will try to use phpsecuresite. In this practice, we build 3 file: form.html for login, login.php for validating, and secretpage.php is a protected page.

form.html

 <html>
 <head>
 <title>Login Page</title>
 </head>
 <body>
 <form action="login.php" method="post">
 Usename: <input type="text" name="username"><br>
 Password: <input type="text" name="password"><br>
 <input type="submit" value="Login">
 </form>
 </body>
 </html>
login.php
 <?php
 require ("./phpsecuresite/phpss/phpss.php");
 
 $status = phpss_login($_POST["username"],$_POST["password"]);
 
 switch($status){
 	case "phpss_login_allow":
 	header("location:secretpage.php");
 	exit();
 	break;
 	
 	case "phpss_login_authfail":
 	print("Your username or password was wrong!");
 	break;
 	
 	case "phpss_login_bruteforce_account_lock":
 	print("Locked, you are naughty!");
 	break;
 	
 	case "phpss_login_bruteforce_iplock":
 	print("Your IP Locked, you are naughty!");
 	break;	
 	
 	default:
 	print("Not Known");
 		
 }
 
 ?>

secretpage.php

 <html>
 <head>
 	<title>Secret Page</title>
 </head>
 <body>
 Wellcome!
 </body>
 </html>
 

Point your browser to http://localhost/test/phpsecuresite/form.html. Try wrong username or password. Then, click login.




Series this article:
PHP Login: Creating Login System Use PhpSecureSite (Introduction)
PHP Login: Installation of phpSecureSite
PHP Login: Configuration of phpSecureSite
PHP Login: Create Example Administrator at phpSecureSite
PHP Login:Creating Login Form Use phpSecureSite
PHP Login: Protecting Page Use phpSecureSite
PHP Login: Creating Logout from phpSecureSite

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting