Page 1 of 1

How Can I Check This?

Posted: Tue Jul 07, 2009 6:28 pm
by jasejunk
How can I check if the text inputted into a form matches the text I want (like a captcha).

Thanks in advance.

Re: How Can I Check This?

Posted: Tue Jul 07, 2009 6:35 pm
by Eric!

Re: How Can I Check This?

Posted: Tue Jul 07, 2009 7:00 pm
by jasejunk
Basically, this is the code I'd like to use.

Code: Select all

<?php
if $_POST['securityAnswer'] == qrjeyas
    {
        header ('Location: /login.html');
    }
?>
But instead of running the script, it just shows the .php page on the site.

The input for this is

Code: Select all

<input name="securityAnswer" maxlength="12" onKeyUp="javascript&#058; return inputLengthCheck(9);" width="300"></td>

Re: How Can I Check This?

Posted: Tue Jul 07, 2009 7:04 pm
by califdon
Assuming that you are trying to compare what was entered with a string, you have to enclose the string in quotation marks.

Re: How Can I Check This?

Posted: Tue Jul 07, 2009 7:30 pm
by jasejunk
Yeah, I fixed that, but still nothing.

Re: How Can I Check This?

Posted: Tue Jul 07, 2009 10:29 pm
by califdon
jasejunk wrote:

Code: Select all

<?php
if $_POST['securityAnswer'] == qrjeyas
    {
        header ('Location: /login.html');
    }
?>
So if the user enters the correct password, you want to redirect to login.html??

Re: How Can I Check This?

Posted: Tue Jul 07, 2009 11:24 pm
by jasejunk
Yes indeed. But only if they enter that. If not, I want it to go to an error screen.
Thanks for your help btw.

Re: How Can I Check This?

Posted: Wed Jul 08, 2009 1:14 am
by insight
jasejunk wrote:Yes indeed. But only if they enter that. If not, I want it to go to an error screen.
Thanks for your help btw.
On your code shouldn't it be like this instead:

Code: Select all

<input name="securityAnswer" maxlength="12" onKeyUp="javascript&#058; return inputLengthCheck(9);" width="300" /></td>
And not
<input name="securityAnswer" maxlength="12" onKeyUp="javascript&#058; return inputLengthCheck(9);" width="300"></td>
Also wouldn't it work if you had an else statement? For example, if the uses uses the correct password then it will direct them to login.html, otherwise it will direct them to an error page.

Code: Select all

  1. <?php
   2. if $_POST['securityAnswer'] == qrjeyas
   3.     {
   4.         header ('Location: /login.html');
   5.     }
   6. ?>
 
Should be
 
   1. <?php
   2. if $_POST['securityAnswer'] == qrjeyas
   3.     {
   4.         header ('Location: /login.html');
   5.     }
   6. else
   7.     {
   8.         header('Location: /error.html');
   9.     }
   10. ?>

Re: How Can I Check This?

Posted: Wed Jul 08, 2009 1:18 am
by SvanteH
Worth noticing that it will treat qrjeyas as an constant (as someone stated earlier).
Always encase strings with " " or ' '
(hint: insight)

:)