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
https://forums.phpfreaks.com/topic/181733-stop-robots-using-validation/
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.

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.