Honey Pot results not working. I need a PHP nudge in the rig

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mguise
Forum Newbie
Posts: 21
Joined: Mon Mar 21, 2011 1:28 pm

Honey Pot results not working. I need a PHP nudge in the rig

Post by mguise »

Hi Everyone

I am trying to cobble together a contact form with a Honey Pot Spam protector. Newby here. I’m basing it off of the following link but I am trying to tweak it so that it will do what I want it to do.

http://devgrow.com/simple-php-honey-pot/

You can see the contact form here http://www.discovermassagespa.com/contact.html.

Please do not look at the php code for http://www.discovermassagespa.com/contactus.php as I am changing that. Please refer to the following code.

Code: Select all

<?php








/* Email Variables */



$emailSubject = 'The Massage Spa';



$webMaster = 'matt@webskillsplus.com';

//$webMaster = 'info@discovermassagespa.com';

//$webMaster = 'murrterr@rcn.com';



/* Data Variables */


$Name = $_POST['Name'];

$LastName = $_POST['LastName'];

$Email = $_POST['Email'];

$Area_Code = $_POST['Area_Code'];

$Phone_Prefix = $_POST['Phone_Prefix'];

$Line_Number = $_POST['Line_Number'];

$help = $_POST['help'];

if (isset($_POST["submit"])) {
echo $_POST["when"];

$robotest = <<<EOD


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
 
 <p>This site is spam protected. If you are human please go back and try again.</p>
<p>The Massage Spa Team.</p>

</body>
</html>


		   
		   EOD;
		   echo "$robotest";
			

  } else {




           
      



$body = <<<EOD

\r\n \r\n <br>

First Name: $Name \r\n <br>

Last Name: $LastName \r\n <br>

Email: $Email \r\n <br>

Phone: $Area_Code $Phone_Prefix $Line_Number \r\n <br>

How can we help you?: $help \r\n <br>

When: $when \r\n <br>

EOD;





$from = "From: info@discovermassagespa.com\r\n";

$from .= "Reply-To: ".$Email."\r\n";

$from .= "Content-type: text/html\r\n";



mail($webMaster, $emailSubject, $body, $from);

/* Prepare autoresponder subject */
$respond_subject = "Thank you for contacting Massage Spa";

/* Prepare autoresponder message */
$respond_message = "Thank you for contacting Massage Spa

Someone will contact you soon.

15966 Hickman Road, Clive Iowa 50325
515.987.4593
info@discovermassagespa.com

Shop Hours: Mon-Fri 10am-9pm, Sa 9am-7pm, Su 11am-4pm 
";

$from = "From: info@discovermassagespa.com\r\n";

/* Send the message using mail() function */
mail($Email, $respond_subject, $respond_message, $from);





/* Results rendered as HTML */




$theResults = <<<EOD

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
 
 <p>Thanks for contacting us.</p>
<p>The Massage Spa Team.</p>

</body>
</html>

EOD;

echo "$theResults";

}

?>
The following is the HTML and the CSS that is relevant to the Honey Pot.

Code: Select all

<p class="robotic" id="pot">
            <label>If you're human leave this blank:</label>
            <input name="robotest" type="text" id="robotest" class="robotest" /></p>

Code: Select all

.robotic { 
  display: none;
}
I’m not sure what I am doing wrong. Thanks in advance for your help.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Honey Pot results not working. I need a PHP nudge in the

Post by twinedev »

First, just to clarify, people cannot see the code on a .php page (From the way you worded it, sounded like you thought we could see the code behind the .php you listed)

Second, onto the form itself:

For the way to hide it, if I remember right, you should not use display: none on it, as a screen reader will skip over display: none. I think that is what I was told why we always did it with just positioning it off of the screen instead.

I am not sure if it is just the way you posted it here or not, but the "EOD;" needs to be at the beginning of the line, you have the first one indented, so PHP will not process the code you have between that and the next <<< EOD

The check you are doing here between the "error message" and actual sending it is based on $_POST['submit'] being present. Instead it should be determined by the field you are expecting to be blank ($_POST['robotest'])

-Greg
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Honey Pot results not working. I need a PHP nudge in the

Post by Weirdan »

twinedev wrote: For the way to hide it, if I remember right, you should not use display: none on it, as a screen reader will skip over display: none. I think that is what I was told why we always did it with just positioning it off of the screen instead.
Generally yes, but this doesn't matter in this case. The field is not expected to be used by humans, even those using screen readers.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Honey Pot results not working. I need a PHP nudge in the

Post by twinedev »

Good point. Think I was thinking more along the lines of kicking text off the screen for when there is a background image that displays the text in it.
mguise
Forum Newbie
Posts: 21
Joined: Mon Mar 21, 2011 1:28 pm

Re: Honey Pot results not working. I need a PHP nudge in the

Post by mguise »

Thanks for all of the responses. :D
Please do not look at the php code for http://www.discovermassagespa.com/contactus.php as I am changing that. Please refer to the following code.
Please ignore, I realized after that fact you could not see that anyway...rooky mistake

I'm gonna slaughter this so please forgive but I'm gonna make a go...
The check you are doing here between the "error message" and actual sending it is based on $_POST['submit'] being present. Instead it should be determined by the field you are expecting to be blank ($_POST['robotest'])
So what you are saying is that I should have something like

Code: Select all

if (isset($_POST["submit"])) {
echo htmlentities($_POST['when']);

if (isset($_POST['robotest'])) {
$robotest = <<<EOD


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Post Reply