Jump to content

banning/redirect after submission!


patentu

Recommended Posts

i have an html page with 3 fields "name,email,message" this goes to done.php done.php process the data and saves "name,email,message,ip" to an .txt file on the server,(IIS6 server 2003)how can i redirect to another page if that IP submitted already?Because i have some "friends" who refreshes the page and i get allot of empty fields :( hope you understand.

Link to comment
Share on other sites

// for your case, example 2 "field2" would be an email field.
//"field4" would be captcha.
if(isset($_POST['submit']))
{

$field1 = $_POST['field1'];
$field2 = $_POST['field2'];
        $field3 = $_POST['field3'];	
if(empty($field1)|| empty($field2)|| empty($field3))
{
	$errors .= "\n Some of the above fields have not been filled in.";	
}
        //Injection not nessessary but recommended to avoid idiots.
if(IsInjected($field2))
{
	$errors .= "\n That email is not valid.";
}
if(empty($_SESSION['field4'] ) ||
strcasecmp($_SESSION['field4'], $_POST['field4']) != 0)
{
	$errors .= "\n Those three characters entered are incorrect. Please try again, alternatively click <a href='javascript:refreshCaptcha();'>here</a> to refresh the characters.";
}
        //start of injection
        function IsInjected($str)
       {
  $injections = array('(\n+)',
              '(\r+)',
              '(\t+)',
              '(%0A+)',
              '(%0D+)',
              '(%08+)',
              '(%09+)'
              );
  $inject = join('|', $injections);
  $inject = "/$inject/i";
  if(preg_match($inject,$str))
    {
    return true;
  }
  else
    {
    return false;
  }
}

 

Remove the captcha part if you don't want it incorporated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.