mercredi 24 décembre 2014

Return only true or false (PHP)

I have this PHP code which should return only either true or false after running multiple stored functions, but unfortunately it does not work as expected. I firstly check the email validation and return true if valid and false if invalid, then i am doing the same for username.



if($_SERVER['REQUEST_METHOD'] == 'POST') {

// Email is valid
if(checkmail($_POST['email'])) {
$_SESSION['v_mail'] = $_POST['email'];
$valid = true;} else { $valid=false; }

// username is valid
if(checkuser($_POST['username'],5,10)) {
$_SESSION['v_username'] = $_POST['username'];
$valid=true;} else { $valid=false; }

}


I need to return only False or True after checking both. I know that it is very small trick but i could not get it.


Aucun commentaire:

Enregistrer un commentaire