mercredi 25 février 2015

Can I use an if statement inside of a switch in php?

Heres what I want to do:


I have a variable named $user, where the information is being POSTED from a form. If the form data is empty I want to do one thing, if the form data is just a comma or symbol I want to do another thing, and if the form data is correct I want to do a third thing. This is how I have it set up, will this work? If not, what can I do to make it work?



switch($user){
case 1:
if(empty($user)){
echo "<h2>"."<strong>"."You entered NOTHING, PLEASE Re-Enter"."</strong>"."</h2>";
}
case 2:
if($user == ",") {
echo "<h2>"."<strong>"."You did not enter any valid names/abbreviations to search, PLEASE Re-Enter"."</strong>"."</h2>";
}
default:


print "==========================================="."<br />";
tester($company, $user);


print "==========================================="."<br />";
print "========The following were NOT found====="."<br />";
notFound($company, $user);

print "==========================================="."<br />";

}


Right now it is automatically going to default. It runs, but I want integrate the two qualifiers, how would I go about doing that?


Aucun commentaire:

Enregistrer un commentaire