+ Reply to Thread
Results 1 to 10 of 17

Thread: PHP Contact form with Captcha

Hybrid View

  1. #1

    Default PHP Contact form with Captcha

    There are a huge number of spambots out there nowadays and they try and use your contact forms to send spam. If you've been slightly careful, the spam is not sent to its intended recipients, but you end up receiving it.

    One way of stopping this is using a Captcha, an image with text which needs to be entered in your form.

    Here follows a brief example;
    File 1: contact.php
    File 2: ocr_captcha.class.php
    File 3: arial.ttf (you'll need to upload this to the same directory as the above files) You can find this file in your %WINDOWS%/fonts directory on your computer

    Put both files in the same directory. Create a new directory "tmp" to hold temp images. Give httpd full permissions on the "tmp" directory
    Make sure you enter your email address in the $email_to value.

    contact_example.zip updated to correct filename typo
    Attached Files Attached Files
    Last edited by whadmin; February 14th, 2007 at 11:24 AM.

  2. #2
    Join Date
    Apr 2006
    Posts
    4

    Default

    Hi Leonard,

    I'm trying to use your php captcha form and everything works great except that it doesn't submit my form to my e-mail. Is there something else that I should do besides the email_to?

    Please forgive me as I'm a designer and not a programmer

    thanks!!!
    Dee

  3. #3

    Default

    Hi Dee,

    This can be caused by a number of server specific settings which would need to be catered for. The most common issue would be your using an email address which does not exist in your account as the $email_to value.

    If you open a support ticket, I will have a look at your setup and let you know which changes need to be made.

    When opening a ticket, please remember to include your HSphere username/login and the domain under which you've installed the script.

    Kind regards,
    Leonard

  4. #4
    Join Date
    Apr 2006
    Posts
    4

    Default

    I had one of my programmer's help me figure it out. Looks like it was the absence of a php.ini file on my server.

    D

  5. #5
    Join Date
    Jul 2006
    Posts
    6

    Default Image error

    Hi Leonard,

    thanks for sharing with us this material. I'm having problems with captcha image generating. the image does not appear. I created the 3 files, contact.php, ocr*.php and I insert arial.tff in the same folder + I created a new folder TMP inside the first one. But its not working, do you have any idea of what I need to insert.
    regards
    sebastian

  6. #6

    Default

    Hi sebastian,

    I'll post an updated package later today which will include some basic checking and debugging.

    Kind regards,
    Leonard

  7. #7

    Default Updated example with checking

    The example has been updated to include some basic checks for file permissions, GD module support and font file existance.

    Just unzip the file and upload to where you want to test.
    Remember, you need to upload the arial.ttf file as well. (Not supplied)

    (UPDATED 02/14/2007 - fixed filename typo)
    Last edited by whadmin; February 14th, 2007 at 11:24 AM.

  8. #8
    Join Date
    Jul 2006
    Posts
    6

    Default Redirect Function

    Hi Leonard,

    thank you so much, its working perfect right now... I want to ask you a question probably you can help me, if I want to redirect the form to a thanks page like
    $location = "thankyou.htm"; what things I need to change, actually I found the last tag in the else loop of the bottom

    mail( $email_to, "Contact Us - Inquire " .$_SERVER['HTTP_HOST'], $message, "From: " .$email_to ."\r\nReply-To: " .$email ."\r\n", "-f" .$email_to );
    echo "Mail Sent to. Thank You!";

    of course I can erase the echo and this would not be printed but I want to add (inside this if just to give the thank you to correct emails sent) a redirect to another page.

    thank you so much.
    Sebastian.

  9. #9
    Join Date
    Jul 2006
    Posts
    6

    Default TMP Writable

    Hi Leonard

    sorry and thanks for your time. I have one more question, if I set TMP folder to writable a Login/pass pop up appear to log in the server to let the captcha image appear. On the other hand if I set the TMP read only no image appear so the form could not work. Do you have any idea why this is happening and how to solve it?.
    best regards
    sebastian

+ Reply to Thread

Similar Threads

  1. Announce: PHP Windows with mailheader patch updated
    By leonard in forum Downloads / Release Notes
    Replies: 1
    Last Post: November 3rd, 2006, 04:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts