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
https://forums.phpfreaks.com/topic/247590-banningredirect-after-submission/
Share on other sites

<?

$visitor = $_SERVER['REMOTE_ADDR'];

if (preg_match("/192.168.0.1/",$visitor)) {

      header('Location: http://www.yoursite.com/thank-you.html');

} else {

      header('Location: http://www.yoursite.com/home-page.html');

};

?>

 

something like this,but i want it to take the ip from a list

// 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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.