943,697 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1235
  • PHP RSS
Sep 16th, 2008
0

Contact Form Spam

Expand Post »
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>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lamarketingfirm is offline Offline
2 posts
since Sep 2008
Sep 16th, 2008
0

Re: Contact Form Spam

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.

PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 21
Solved Threads: 11
Junior Poster
MVied is offline Offline
111 posts
since Aug 2008
Sep 17th, 2008
0

Re: Contact Form Spam

You can install latest captcha as well.
Reputation Points: 769
Solved Threads: 128
Banned
ithelp is offline Offline
1,910 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Store pics in database
Next Thread in PHP Forum Timeline: Static URL to Dynamic URL





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC