Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Captcha security code script

Options
  • 30-11-2006 1:05pm
    #1
    Registered Users Posts: 673 ✭✭✭


    Hi,

    Im trying to get the Captcha security code script to work on my site. The security code is stored in a session but when i try to recall the session code to compare to the code that the user entered it is empty.

    If i already have started a session to hold my users login information can i start another session to hold the security code info or is this what is causing the security code session not to transfer?

    Thanks


Comments

  • Registered Users Posts: 673 ✭✭✭Bananna man


    Ok,

    I had the CaptchaSecurityImages.php file in a subfolder, when i moved this into the same folder as the file that was using the function the session code is now being transfered for some reason. But now the bloody Captcha image isint showing up. Why will it show when CaptchaSecurityImages.php is stored in a sub folder but not when its in the parent folder????????


  • Registered Users Posts: 673 ✭✭✭Bananna man


    Seems the problem is that Captcha doesnt bloody work in firefox. Tried it in IE and it seems to be working. Anyone else know about this problem?


  • Registered Users Posts: 683 ✭✭✭Gosh


    With regard to the session problem make sure you have session_start() in the php code that is checking the security code.

    As for the other problem using CaptchaSecurityImages.php - there's a few problems with this. If you move the php code you must move the ttf font file with it. Another problem is that this will not work on PHP 4.4.x - as there's a problem with with accessing the ttf file - the imagettftext function doesn't return the text in the box.

    I had this working under PHP 5 but had the above problem with PHP 4.4.2, the only way to get around it was to replace the imagettftext function with imagestring

    [php]
    imagestring($image, 5, 20, 10, $code, $text_color);
    [/php]


  • Registered Users Posts: 683 ✭✭✭Gosh


    Seems the problem is that Captcha doesnt bloody work in firefox. Tried it in IE and it seems to be working. Anyone else know about this problem?

    I've only ever used FF and never had a problem


  • Registered Users Posts: 673 ✭✭✭Bananna man


    Doh!!

    When i try it in IE it seems to work but when i try it in firefox it says the security code did not match. I have put in
    echo "session code =".$_SESSION['security_code_session'];
    
    to view the session security code that is being passed and this is staying blank in both IE and firefox.

    Also, i have a session start on each page.


  • Advertisement
  • Registered Users Posts: 683 ✭✭✭Gosh


    If you've not made changes to CaptchaSecurityImages (assuming you got this from www.white-hat-web-design.co.uk) then you should be doing the following:



    [php]
    if(($_SESSION == $_POST) && (!empty($_SESSION)) ) {
    // code here for match on security_code
    } else {
    // code here for mismatch on security_code
    }
    [/php]


  • Registered Users Posts: 673 ✭✭✭Bananna man


    Gosh wrote:
    If you've not made changes to CaptchaSecurityImages (assuming you got this from www.white-hat-web-design.co.uk) then you should be doing the following:



    [php]
    if(($_SESSION == $_POST) && (!empty($_SESSION)) ) {
    // code here for match on security_code
    } else {
    // code here for mismatch on security_code
    }
    [/php]

    Yep thats where i got it from and thats what i have. I think the problem lies in the fact that when i try to echo the session secutrity code is coming up blank which shouldnt be happening.


  • Registered Users Posts: 683 ✭✭✭Gosh


    That's because

    [PHP]
    echo "session code =".$_SESSION;
    [/PHP]

    should be

    [PHP]
    echo "session code =".$_SESSION;
    [/PHP]


  • Registered Users Posts: 673 ✭✭✭Bananna man


    I'd just noticed that myself, that was from something i tried a while ago. Doh. Anyways, i changed it around, now when it echo's out in IE it comes up as: session code =2rhwm5security (with scurity at the end of the number) this seems to work but in Firefox this comes up: session code =security and gives the "not the same codes" error.


  • Registered Users Posts: 683 ✭✭✭Gosh


    Check FF Tools>Options on the Privacy section check Cookies and make sure you allow sites to set cookies.


  • Advertisement
  • Registered Users Posts: 673 ✭✭✭Bananna man


    Thought of that already but thats set to "allow sites to set cookies". Thanks for all the help on this by the way :)


  • Registered Users Posts: 673 ✭✭✭Bananna man


    Thought of that already but thats set to "allow sites to set cookies". I dont have problems on other sites that need cookies either.

    Thanks for all the help on this by the way :)


  • Registered Users Posts: 683 ✭✭✭Gosh


    Run out of ideas, have you shut down FF and restarted to start a new session? Don't understand why you should be getting the word security after the code unless this is coming from another echo.


  • Registered Users Posts: 673 ✭✭✭Bananna man


    Ok, thanks for all the help anyway. I just tried it on another pc and am getting exectly the same results i.e. working on IE but not on Firefox.

    Do you know of any other scripts that i can use instead of this one, im srewed if i cant get this working.


  • Registered Users Posts: 683 ✭✭✭Gosh


    Check your <img and <input field as documented on www.white-hat-web-design.co.uk

    I have had it working in both IE and FF - could be something like a missing > in your HTML that IE copes with and FF doesn't


  • Registered Users Posts: 673 ✭✭✭Bananna man


    The image is showing up fine in Firefox and i am currently doing an echo on the security code the user enters and that is passing fine too. The only thing that isint working is the session security code, doesnt appear when i echo it in firefox just gives me the security text with no code.

    My God, im at this 6 hours now :mad:


  • Registered Users Posts: 683 ✭✭✭Gosh


    PM sent


Advertisement