Jump to content

stop robots using validation


ident

Recommended Posts

I'm using a textbox called norobots

 

This page formhandler uses emailhandle.php and we seem to be getting a high number of emails sent. So to stop robots using are site i added the textbox norobots.

 

The verification is the users ip. and the textbox says add your ip address here.

 

My problem is i dont know how to compare the textbox input to the users ip address. my code for handle email is below.

 

If the ip's dont match i want it to go to a error page but if it matches i want it to send

 

<?php
//add the header
include('header.php');

//define the receiver of the email
$to = $_POST["to"];
//define the subject of the email
$subject = htmlentities($_POST["subject"], ENT_QUOTES);
//define the message to be sent. Each line should be separated with \n

// http://www.simplecoders.com/showpic.php?f=IR6eC3zS2w41wA.jpg
$url_bits = parse_url($_POST['rawlink']);
if( !preg_match('/f=[a-z-A-Z0-9]+\.[a-z]{1,3}/', $url_bits['query']) ) {
echo "bad link";
die;
}

$_POST['msg'] = str_replace('[iMAGE]', $_POST['rawlink'], $_POST['msg']);
$message =  htmlentities($_POST["msg"], ENT_QUOTES) . "\n\n\n\n******************************************\n\nFree image hosting at www.simplecoders.com\n\nThe Simple Coders Team ";

$headers = "From: SimpleCoders\r\nReply-To: support@simplecoders";
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );

echo $mail_sent ? "<br /><center>Mail sent" : "Mail failed";
echo "<br /><a href=\"Upload.php\">Click here to go back to the previous page</a></center>";

?>

Link to comment
Share on other sites

Hi. iv made it quite clear as picture shows.

 

i have got this

 

<?php
// entered IP address
$enteredIpaddress = $_POST['norobots'];



// Actual IP address
$usersIpaddress = $_SERVER['REMOTE_ADDR'];




// GO COMPARE!!!!11111
if ($enteredIpaddress != $usersIPaddress) {


// if wrong IP entered redirect to google or what ever!
header('location: http://www.google.co.uk');


} else {

// DO all this if the IP's match!

//add the header
include('header.php');


//define the receiver of the email
$to = $_POST["to"];



//define the subject of the email
$subject = htmlentities($_POST["subject"], ENT_QUOTES);





//define the message to be sent. Each line should be separated with \n
// http://www.simplecoders.com/showpic.php?f=IR6eC3zS2w41wA.jpg
$url_bits = parse_url($_POST['rawlink']);
if( !preg_match('/f=[a-z-A-Z0-9]+\.[a-z]{1,3}/', $url_bits['query']) ) {
	echo "bad link";
	die;
}

$_POST['msg'] = str_replace('[iMAGE]', $_POST['rawlink'], $_POST['msg']);
$message =  htmlentities($_POST["msg"], ENT_QUOTES) . "\n\n\n\n******************************************\n\nFree image hosting at 
www.simplecoders.com\n\nThe Simple Coders Team ";

$headers = "From: SimpleCoders\r\nReply-To: support@simplecoders";


//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );

echo $mail_sent ? "<br /><center>Mail sent" : "Mail failed";
echo "<br /><a href=\"Upload.php\">Click here to go back to the previous page</a></center>";

}

?>

 

showpic.php?f=ox5dRl6TBJ9lOV.png

 

but it always goes to google.

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.