views:

314

answers:

4

I might be going about this the wrong way

I have a landing page that has a form on it. When i post that page the values of the from got to a page called mail.php

I wanted to add a captcha ( in this case re-captcha.com) to the first page to prevent people from spaming my job application site.

I am unsure how to use the php captcha to prevent people from posting but i was thinking that i could use it to set a boolean variable that i send to my mail.php page that will tell it weather or not to acutally send me a job applicants email.

1) how do I pass a variable from one php page to another?

2) is there a better way to use the captcha (im still new to php and web programing so i maybe going the long way around an easy question)

thanks

A: 

The form values will be available in either the $_POST variable or the $_GET variable, depending on how you submitted the form (whether the "mode" attribute of your HTML form tag was set to "post" or "get").

Tom
so If i just made a $captcha = true on the other form i would say $whatever = $_post[$captcha];????
Crash893
A: 

1) You have several methods for passing variables from one page to another but for the most part it relies on the client and session handling. A few of the simplest:

-You can include a hidden form property to pass a variable that you set and it will be posted to the page along with your forms. (input type=hidden)

-You can set the variable in the users session cookies.

-You can use a session id to reference a set variable in your database.

2) There are a lot of ways to use captcha, but if you want to continue with recaptcha take a look at their documents http://recaptcha.net/plugins/php/ http://recaptcha.net/apidocs/captcha/client.html http://wiki.recaptcha.net/index.php/Main%5FPage

BrandonCS
so in the top part of my form i would put "<INPUT TYPE = "hidden" VALUE ="False" NAME = "captcha">" and then in the conditional of the captcha how would i change the value to true?
Crash893
To be completely honest I wouldn't recommend relying on the form submission in such a way to validate the captcha. I'd highly recommend looking through the API and the PHP classes and implementing them as such. If you use JS or something else to change your hidden variable you would be opening your software up to a bot changing the value itself and then submitting the true value, completely defeating the purpose.
BrandonCS
+1  A: 

while i have no experience in captcha,

1) how do I pass a variable from one php page to another?

use the $_SESSION var to pass them.

http://us3.php.net/manual/en/book.session.php

centr0
+1  A: 

You might look at also using Secureimage PHP Captcha, it also works really well and they have some good sample code.

Also, check out this article on implementing PHP and reCaptcha

meme
I prefer re-captcha just becuase i like the work they do. but thanks for the link
Crash893