SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php captcha and cgi?

    hello peeps,
    I have found this excellent php captcha class at:

    http://www.ejeliot.com/pages/2

    it works a treat up to a point. posting data across a form and it works wonderfully, but what I am having trouble with is posting the the contents of my mail form to the formmail-clone.cgi script on my website.

    My mail form action is to a formmail-clone.cgi script and as a result the phpcaptcha cannot be verified as it would against the supplied form.php example.

    Is there a way to verify the captcha before the mail is sent to the cgi script?
    This has been boiling my swede for the last three days. If someone could point me in the right direction, they would become my most recent hero.
    people in glass houses shouldn't walk around naked

  2. #2
    SitePoint Enthusiast shredder-man's Avatar
    Join Date
    Sep 2007
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One way of doing it would be to send your forms using PHP and not the cgi-bin but I don't know if you would be up with that.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually I have been trying to do that exactly the way you are suggesting. I've got the data passing over if the captcha code is inserted corrrectly. What I am now having trouble with is posting the data to the email address. Any ideas? please? thanks in advance to anyone willing to help.
    Last edited by chris davies; Oct 12, 2007 at 08:03. Reason: typo
    people in glass houses shouldn't walk around naked

  4. #4
    SitePoint Member
    Join Date
    Oct 2007
    Location
    Australia
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for sharing the link. I'll check this one out.
    Free Internet Business Videos, Tips and
    Podcast at The Unstoppable Profits Blog:

    Click Here To Visit The Unstoppable Profits Blog

  5. #5
    SitePoint Enthusiast shredder-man's Avatar
    Join Date
    Sep 2007
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have used this in the past and has worked great:

    create a file called verify.php
    Code:
    <?
    session_start();
    $text = rand(10000,99999);
    $_SESSION["vercode"] = $text;
    
    $height = 25;
    $width = 65;
    
    $image_p = imagecreate(65, 25) or die ("Cannot Initialize new GD image stream");
    $black = imagecolorallocate($image_p, 0, 0, 0);
    $white = imagecolorallocate($image_p, 255, 255, 255);
    $font_size = 14; 
    imagestring($image_p, $font_size, 5, 5, $text, $white);
    imagejpeg($image_p, null, 80);
    ?>
    Then, in your form put this as your input verification box (which links to the above code):
    Code:
    <img src="verify.php"><br><br><input name="vercode" type="text">
    On top of whatever page your action in the form is set to, have this php code:

    Code:
    <?php
    session_start();
    if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='')  {
    //Do whatever you want it to do if they entered in the wrong code
    }
    else
    {
    //send your form
    }
    session_destroy();
    ?>

  6. #6
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the code, but I'm not having trouble sending the data to a form once the captcha code is verified. What I can't do is send the data to an email address after verification. Any ideas on this one? I have tried using the php mail function but the mail is not being posted.
    people in glass houses shouldn't walk around naked


Bookmarks

Posting Permissions

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