How Can I Check This?
Moderator: General Moderators
How Can I Check This?
How can I check if the text inputted into a form matches the text I want (like a captcha).
Thanks in advance.
Thanks in advance.
Re: How Can I Check This?
Some basic starting points
http://php.net/manual/en/control-structures.if.php
and
http://us2.php.net/manual/en/function.strcasecmp.php
http://php.net/manual/en/control-structures.if.php
and
http://us2.php.net/manual/en/function.strcasecmp.php
Re: How Can I Check This?
Basically, this is the code I'd like to use.
But instead of running the script, it just shows the .php page on the site.
The input for this is
Code: Select all
<?php
if $_POST['securityAnswer'] == qrjeyas
{
header ('Location: /login.html');
}
?>The input for this is
Code: Select all
<input name="securityAnswer" maxlength="12" onKeyUp="javascript: return inputLengthCheck(9);" width="300"></td>Re: How Can I Check This?
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?
Yeah, I fixed that, but still nothing.
Re: How Can I Check This?
So if the user enters the correct password, you want to redirect to login.html??jasejunk wrote:Code: Select all
<?php if $_POST['securityAnswer'] == qrjeyas { header ('Location: /login.html'); } ?>
Re: How Can I Check This?
Yes indeed. But only if they enter that. If not, I want it to go to an error screen.
Thanks for your help btw.
Thanks for your help btw.
Re: How Can I Check This?
On your code shouldn't it be like this instead: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.
Code: Select all
<input name="securityAnswer" maxlength="12" onKeyUp="javascript: return inputLengthCheck(9);" width="300" /></td>
And not
<input name="securityAnswer" maxlength="12" onKeyUp="javascript: return inputLengthCheck(9);" width="300"></td>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?
Worth noticing that it will treat qrjeyas as an constant (as someone stated earlier).
Always encase strings with " " or ' '
(hint: insight)

Always encase strings with " " or ' '
(hint: insight)