Contact Form Spam

Reply

Join Date: Sep 2008
Posts: 2
Reputation: lamarketingfirm is an unknown quantity at this point 
Solved Threads: 0
lamarketingfirm lamarketingfirm is offline Offline
Newbie Poster

Contact Form Spam

 
0
  #1
Sep 16th, 2008
I have a website that I just created a contact form for. However. it seems like a bot has hit the form, and continously fills out emails. I don't know php very well - and someone else did most of the work.

I don't want to put a captcha in, as it reduces the amount of people that will fill out the form. Instead, I'd like to make a "do or die" code that requires the user to fill out a phone number.

Here's the current code. What should I do to fix it?

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

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>

<!-- Reminder: Add the link for the 'next page' (at the bottom) -->
<!-- Reminder: Change 'YourEmail' to Your real email -->

<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitormail = $_POST['email'];
$comments = $_POST['comments'];
$case_description = $_POST['case_description'];
$phone = $_POST['phone'];
$street = $_POST['address'];
$yourname = $_POST['name'];

$todayis = date("l, F j, Y, g:i a") ;

$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
From: $yourname ($visitormail)\n
Phone Number: $phone \n
Address: $street \n
Comments: $comments \n
Case Description: $case_description \n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";

mail("jcernamonroe@yahoo.com", "Contact Info from Exclusively Criminal Deffense", $message, $from);

?>

<p align="center">
<SCRIPT LANGUAGE="JavaScript">
window.location="../success.html";
</script>

</body>
</html>
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 84
Reputation: MVied is an unknown quantity at this point 
Solved Threads: 5
MVied's Avatar
MVied MVied is offline Offline
Junior Poster in Training

Re: Contact Form Spam

 
0
  #2
Sep 16th, 2008
The phone number is a good idea as a spam bot probably won't fill that in correct, especially if we validate it.

This method will accept a 10 digit phone number with spaces, dashes, or neither.

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Sendemail Script</title>
  6. </head>
  7. <body>
  8.  
  9. <!-- Reminder: Add the link for the 'next page' (at the bottom) -->
  10. <!-- Reminder: Change 'YourEmail' to Your real email -->
  11.  
  12. <?php
  13.  
  14. $ip = $_POST['ip'];
  15. $httpref = $_POST['httpref'];
  16. $httpagent = $_POST['httpagent'];
  17. $visitormail = $_POST['email'];
  18. $comments = $_POST['comments'];
  19. $case_description = $_POST['case_description'];
  20. $phone = $_POST['phone'];
  21. $street = $_POST['address'];
  22. $yourname = $_POST['name'];
  23.  
  24. $todayis = date("l, F j, Y, g:i a") ;
  25.  
  26. $subject = $attn;
  27.  
  28. $notes = stripcslashes($notes);
  29.  
  30. $message = " $todayis [EST] \n
  31. From: $yourname ($visitormail)\n
  32. Phone Number: $phone \n
  33. Address: $street \n
  34. Comments: $comments \n
  35. Case Description: $case_description \n
  36. Additional Info : IP = $ip \n
  37. Browser Info: $httpagent \n
  38. Referral : $httpref \n
  39. ";
  40.  
  41. $from = "From: $visitormail\r\n";
  42.  
  43.  
  44. if (!preg_match('/^\d{3}[\s-]?\d{3}[\s-]?\d{4}$/', $phone)) {
  45. echo 'The phone number you provided was invalid.';
  46. } else {
  47. mail("jcernamonroe@yahoo.com", "Contact Info from Exclusively Criminal Deffense", $message, $from);
  48. ?>
  49. <p align="center">
  50. <SCRIPT LANGUAGE="JavaScript">
  51. window.location="../success.html";
  52. </script>
  53. <?php } ?>
  54. </body>
  55. </html>
Last edited by MVied; Sep 16th, 2008 at 6:47 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,845
Reputation: ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all 
Solved Threads: 119
ithelp's Avatar
ithelp ithelp is offline Offline
Posting Virtuoso

Re: Contact Form Spam

 
0
  #3
Sep 17th, 2008
You can install latest captcha as well.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC