Jump to content

Blocking SPAM mails in back-end file


aamberker

Recommended Posts

Hi,Very often I am getting the following spams [bots] in my Gmail ID :)

The following information has been submitted.:name -- dasdjemail -- dasdj@mail.comphone -- KkXBQzbgtIWYLnocomments -- http://www.youtube.com/xanaxstore%20\" target="_blank">Xanax Online Storehearaboutus -- Select
The FORM tag in HTML file goes like this -
<form action="formmail.php" method="post" name="Base" id="Base" onSubmit="return checkForm();"> <table width="350" border="0"> <tr> <td width="107" class="text_1"><span class="text_1"><strong>Name:</strong></span></td> <td width="233"> <input type="text" name="name" size="20" style="background-color: #D4D0C8"></td> </tr> <tr> <td class="text_1"><strong>E-mail:</strong></td> <td><input type="text" name="email" size="20" style="background-color: #D4D0C8"></td> </tr> <tr> <td class="text_1"><strong>Phone:</strong></td> <td class="text_1"> <input type="text" name="phone" size="20" style="background-color: #D4D0C8">  (Optional)</td> </tr> <tr> <td valign="top" class="text_1"><strong>Comment:</strong></td> <td> <textarea name="comments" cols="25" rows="4" id="comments" style="background-color: #D4D0C8"></textarea></td> </tr> <tr> <td class="text_1 style1"><strong class="text_1">How did you Hear About Us :</strong></td> <td> <select name="hearaboutus" id="hearaboutus" style="width:146px;" style="background-color: #D4D0C8"> <option selected>Select</option> <option>Google</option> <option>AOL</option> <option>Yahoo</option> <option>Client</option> <option>Ad</option> <option>Radio</option> <option>Other</option> </select></td> </tr> <tr> <td class="text_1 style1"> </td> <td> </td> </tr> <tr> <td class="text_1 style1"> </td> <td><input type="submit" name="Submit" value="Submit">  <input type="reset" name="Reset" value="Reset"></td> </tr> </table></form>
The PHP Backend file [formmail.php] goes like this -
<?/* The text to be added to your HTML page is: action="formmail.php" to be added to form tag. assuming that formmail.php is in the same folder.<form id="form1" name="form1" method="post" action="formmail.php">*//*********************************************************************************/// Set the names of input tags present in the form here.$myInputs = array("name","email","phone","comments","hearaboutus");$From="contact@domain.com"; //from email Id$To = "AAA@domain.com"; //to email Id$Subject = "Visitor's Information from the Contact Us page!"; // set the Email Message subject $responseMessage = "Testing!... Testing!... Testing!..."; //The message that need to be displayed after submission./*********************************************************************************/if ($HTTP_SERVER_VARS["REQUEST_METHOD"]=="POST") { $emailMsg = "The following information has been submitted.:\n\n"; for ($i=0;$i<count($myInputs);$i++) { $emailMsg .= $myInputs[$i]." -- ".$_REQUEST[$myInputs[$i]]."\r\n"; } // Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer $pattern = '/(;|\||`|>|<|&|^|"|{|}|[|]|\)|\()/i'; // build the pattern match string $emailMsg = preg_replace($pattern, "", $emailMsg); $emailMsg .= "\n\n"; $headers = "From: $From\nReturn-Path: ".$tReturn."\ncc:BBB@domain.com,CCC@domain.com\n"; $emailOk=mail($To,$Subject,$emailMsg,$headers); // if ($emailOk) print $responseMessage;} //Posting ?><script>location.href="http://www.domain.com/thankyou.html"</script>
Wondering how to get-ride of Spams [bots] in my Gmail ID :) By the way - As suggested by justsomeguy I updated as following in my HTML file
<tr><td width="107" class="text_1"><span class="text_1"><strong>Name:</strong></span></td><td width="233"><input type="text" name="name" size="20" style="display: none;"><input type="text" name="dj39edc8" size="20" style="background-color: #D4D0C8"></td></tr><tr><td class="text_1"><strong>E-mail:</strong></td><td><input type="text" name="email" size="20" style="display: none;"><input type="text" name="cqwze803m" size="20" style="background-color: #D4D0C8"></td></tr><tr><td class="text_1"><strong>Phone:</strong></td><td class="text_1"><input type="text" name="phone" size="20" style="display: none;"><input type="text" name="zxbm720elk5" size="20" style="background-color: #D4D0C8"> (Optional)</td></tr><tr><td valign="top" class="text_1"><strong>Comment:</strong></td><td><textarea name="comments" cols="25" rows="4" id="comments" style="display: none;"></textarea><textarea name="rdx007bmw843" cols="25" rows="4" id="comments" style="background-color: #D4D0C8"></textarea></td></tr>
Wondering how to get-ride of Spams [bots] in my Gmail ID :mellow:
Link to comment
Share on other sites

Are you saying that after JSG's suggestions you are still getting spambots sending mail with your form?

Link to comment
Share on other sites

Are you saying that after JSG's suggestions you are still getting spambots sending mail with your form?
I just followed JSG's suggestions in HTML file... I need to do something [modify / update] in php file. Now sure how to proceed further... I guess only JSG can help me to solve this issue.
Link to comment
Share on other sites

Oh - you have to change the $myInputs array

// Set the names of input tags present in the form here.$myInputs = array("name","email","phone","comments","hearaboutus");

to the new (random) names you gave your form fields.

Link to comment
Share on other sites

Oh - you have to change the $myInputs array
// Set the names of input tags present in the form here.$myInputs = array("name","email","phone","comments","hearaboutus");

to the new (random) names you gave your form fields.

Oh Really??? hummmm... Are you referring about the following -name - dj39edc8email - cqwze803mphone - zxbm720elk5comments - rdx007bmw843But heyy... HOLD ON... As per JSG's suggestions, it was something else... He suggested -
<?php$spam = $_POST['name'];$name = $_POST['dj39edc8'];if ($spam != ""){ //bot}else{ //human}?>
Wondering how to incorporate in my PHP file... :)
Link to comment
Share on other sites

TutorialHave a look here...Justsomeguy helped me with this bit of code.
Thank you Hooch... But difficult to understand that Tutorial... I am waiting for Justsomeguy's message.
Link to comment
Share on other sites

  • 2 weeks later...

What they're saying is right, you need to change the names that the PHP file is looking for here:// Set the names of input tags present in the form here.$myInputs = array("name","email","phone","comments","hearaboutus");You also want to add some code that checks for the hidden inputs and quits if any of them are non-empty (like the code you quoted).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...