0

I am trying a new CAPTCHA Script from here. To call the CAPTCHA code you use: $_SESSION['captcha']['code']

Well that works when I echo it out on the main form, but when I echo it after the form has been submitted, it displays a new code so I can never find out what the old code was when they submitted the form.

if($_POST['submit']) {
    echo $_SESSION['captcha']['code'];
}

How can I save that session data and not make it change any more?

2
  • You need verify if your captcha code is rewrite the session variable when the page reload. Probably you'll need make changes on this code. Commented Sep 2, 2011 at 13:32
  • You can put here the code that generate and store captcha on session Commented Sep 2, 2011 at 13:33

3 Answers 3

3

You should store it in your own SESSION variable:

$_SESSION['old_captcha'] = $_SESSION['captcha'];

Then, when the form is submitted, use you own variable:

if($_POST['submit']) {
    echo $_SESSION['old_captcha']['code'];
}
Sign up to request clarification or add additional context in comments.

Comments

2

Put that BEFORE you include the captcha.php again on the next step.

Comments

1

My guess is that it displays a new code because you come back to the page that displays it. Try submitting to a different page, or maybe not executing the captcha creation code if the session variable is already set.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.