adnana1024 Posted July 29, 2009 Share Posted July 29, 2009 I have a simple PHP web contact form for a website. I need to add an anti-spam captcha to prevent all the spam emails I've been getting. The problem is, I don't really know PHP, and do not know ho to implement such a code into the form. I really need help with this. Here is the code for the contact page: <? if ($form_submit == "yes") { if (!$fullname || !$phone) { $error = "<font size=\"2\" color=\"#990000\"><b>Sorry, please fill in the required information.</b></font><br><br>"; } else { $name = stripslashes($name); $phone = stripslashes($phone); $email = stripslashes($email); //CONSTRUCT AND SEND EMAIL-------------------------------------------------------------------------------------------------------------------------- $msg = "Someone has filled out the website contact form.\n Full Name: $fullname Company/Organization Name: $compname Address: $address City: $city State: $state Zip Code: $zip Phone: $phone Cell Phone: $cell Email: $email Best time to call: $time Comments: $comments "; $to = "[email protected]"; $subject = "Contact Form "; $mailheaders = "From: $email <>"; mail($to, $subject, $msg, $mailheaders); header("Location: freewebdevelopmentquote_redirect.html"); exit; } //end if } //end if ?> <html> <head> <table width="900" height="637" background="images/freequote-bg.jpg"> <tbody> <tr> <td> <form action="freewebdevelopmentquote.php" method="post" name="FormName"> <div align="center" class="style3"> <span class="style11"> <input type="hidden" name="form_submit" value="yes"> Please fill out the form below to recieve a free estimate!</span><br> </div> <div align="center"><? echo "$error"; ?><br> <table width="470" border="0" cellspacing="2" cellpadding="2"> <tr> <td align="left" width="150"><span class="text_normal style3 style9 style11"><strong>Full Name: <span class="style7">(*required) </span></strong></span></td> <td align="left"><input type="text" name="fullname" size="25" /></td> </tr> <tr> <td align="left" width="150"><span class="text_normal style3 style9 style11"><strong>Company/Organization Name: </strong></span></td> <td align="left"><input type="text" name="compname" size="25" /></td> </tr> <tr> <td align="left" width="150"><span class="text_normal style3 style9 style11"><strong>Address:</strong></span></td> <td align="left"><input type="text" name="address" size="25" /></td> </tr> <tr> <td align="left" width="150"><span class="text_normal style3 style9 style11"><strong>City:</strong></span></td> <td align="left"><input type="text" name="city" size="25" /></td> </tr> <tr> <td align="left" width="150"><span class="text_normal style3 style9 style11"><strong>State:</strong></span></td> <td align="left"><select name="state" size="1"> <option></option> <option value="AK">AK</option> <option value="AL">AL</option> <option value="AR">AR</option> <option value="AZ">AZ</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DC">DC</option> <option value="DE">DE</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="IA">IA</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="MA">MA</option> <option value="MD">MD</option> <option value="ME">ME</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MO">MO</option> <option value="MO">MS</option> <option value="MT">MT</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="NE">NE</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NV">NV</option> <option value="NY">NY</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VA">VA</option> <option value="VT">VT</option> <option value="WA">WA</option> <option value="WI">WI</option> <option value="WV">WV</option> <option value="WY">WY</option> </select></td> </tr> <tr> <td align="left" width="150"><span class="text_normal style3 style9 style11"><strong>Zip Code:</strong></span></td> <td align="left"><input type="text" name="zip" size="12" /></td> </tr> <tr> <td align="left" width="150"><span class="text_normal style3 style9 style11"><strong>Phone: <span class="style7">(*required) </span></strong></span></td> <td align="left"><input type="text" name="phone" size="20" /></td> </tr> <tr> <td align="left" width="150"><span class="text_normal style3 style9 style11"><strong>Cell Phone:</strong></span></td> <td align="left"><input type="text" name="cell" size="20" /></td> </tr> <tr> <td align="left" width="150"><span class="text_normal style3 style9 style11"><strong>Email:</strong></span></td> <td align="left"><input type="text" name="email" size="25" /></td> </tr> <tr> <td align="left" width="150"><span class="text_normal style3 style9 style11"><strong>Best time to call:</strong></span></td> <td align="left"><input type="text" name="time" size="25" /></td> </tr> <tr> <td align="left" width="150"><span class="text_normal style3 style9 style11"><strong>Comments:</strong></span></td> <td align="left"><textarea name="comments" cols="30" rows="5"></textarea></td> </tr> <tr> <td align="left" width="150"></td> <td align="left"><input type="submit" name="submitButtonName" value="Submit" /><input type="reset" /></td> </tr> </table> <div align="center" class="style6"> <p><span class="style7">Privacy Policy:</span> <span class="style11">We will not use your information on any email or mailing list.<br> </span><span class="style11">Your information is confidential and not given to a third party. We follow an anti-spam policy. </span></p> </div> <p> </p> </div></form></td></tr> <!-- ** END OF FORM ** --> <tr><td> </td> </tr> </tbody> </table> </body> </html> Thank you so much for taking the time to look at this, and I really hope on of you has a solution. Link to comment https://forums.phpfreaks.com/topic/168040-need-help-inserting-captcha-code-into-an-already-existing-web-form/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.