Page 1 of 1
best way to pas $var from image gen to script
Posted: Thu Jul 07, 2011 4:15 pm
by jonathon
I've built a random generated captcha for a contact form, so It creates a random 5 letter string and then creates an image. I then call this script as an image source from my contact page. But I need to verify the correct input of the captcha. I'm using a self verifying contact form so contact.php posts to contact.php, so i'm trying to think of the best way to validate that the capctha is correct. Has anyone got any advice?
Currently i'm slightly concerned that i'll just overwrite the capctha value every time the form is validated
Thanks in advance if anyone has any good ideas
Re: best way to pas $var from image gen to script
Posted: Thu Jul 07, 2011 5:36 pm
by conradk
Validate the captcha value before the captcha is generated on Contact.php
Create a variable that stores whether or not the captcha was entered correctly. If not, just show a new captcha. If it was entered correctly, process the form values
Re: best way to pas $var from image gen to script
Posted: Thu Jul 07, 2011 5:47 pm
by jacek
To add to the above, make sure you do that check before the code that generates a new code. That way, if the user enters the correct code, the form will be processed before the new code is generated.
Re: best way to pas $var from image gen to script
Posted: Thu Jul 07, 2011 6:18 pm
by jonathon
I'm not sure its possible the way I have it set up.
My verify.php file generates the random string
In my contact.php file within the <form> tags i call the script as an image so:
<img src="verify.php" />
So on that basis I can't validate the input can i? :s
Re: best way to pas $var from image gen to script
Posted: Thu Jul 07, 2011 9:29 pm
by jacek
You could store the key in the session to get it back to the main page.
Re: best way to pas $var from image gen to script
Posted: Thu Jul 07, 2011 10:30 pm
by jonathon
Hmmm, yes i thought that i'd possibly have to go down the session route. Thanks for your help Jacek, I'll get on the session approach