Home Php PHP Cookies and Sessions Flood protection using cookies Tutorial
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

PHP Cookies and Sessions Flood protection using cookies Tutorial

Advertisement
Cookies are an integral part of any good website, learn one application of them here.

PHP Flood Protection using session

     

In the following tutorial we will learn how to stop the undue input from user, to put such kind of constraint you can use the following code. This script prevents users  from flooding (posting excessive useless messages) your shout box, poll, comments area, forum etc. To do this, we have to use session, a valuable part of php

Example 1:

<?php

SESSION_start();

if(isset($_SESSION['view']))

{

if($_SESSION['view']< 5)

{

$_SESSION['view']+=1;

$name=$_POST['name'];

$passwd=$_POST['password'];

if($name=='demo'&& $passwd=='demo')

{

echo "hello $name";

}

else

{

 header('Location:session.html');

}

}

else

{

echo"<br/>Sorry your maximum turn exceed";

session_destroy();

SESSION_start();

$_SESSION['view']=0;

}

}

?>

Output:

If you enter demo in both the text boxes, output will be:

hello demo

Otherwise if maximum turn exceed more than 4 times, output will be:

Sorry your maximum turn exceed

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 12, 2009

Related Tutorials

Ask Questions?    Discuss: PHP Cookies and Sessions Flood protection using cookies Tutorial  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com