mardi 2 septembre 2014

How to use PHP to check form field for specific value?


Vote count:

-1




How to use PHP to check form field for specific value?


The value '7' would need to be inserted or else the form field will be invalid; so invalid with all other numbers then 7.



if(empty($_POST['captcha']))
{
$this->add_error("Did you solve the captcha?");
$ret = false;
}


Works to check if any value -- but I need to specify, must be 7.



if(strlen($_POST['captcha']) =!7) // tried this but form completely died or disappeared
{
$this->add_error("Did you solve the captcha?");
$ret = false;
}


asked 1 min ago


1 Answer



Vote count:

0




You have two problem:


=! should be !=



if(strlen($_POST['captcha']) != 7)


You also need to turn on error reporting.



answered 15 secs ago






How to use PHP to check form field for specific value?

Aucun commentaire:

Enregistrer un commentaire