vendredi 6 mars 2020

$_post varaible foreach loop logic problem

this code should check the input if its found in the array ,but it does not it just works for the first index [0]

$array=array("joe",
            "sarah",
            "jaison",
            "klai",
            "hanna");
if ($_POST){
    foreach($array as $value){
        echo $value;
        if($_POST["name"]==$value){
            echo "yeb,i know him !";
            break;
        } else {
            echo "i dont know him";
            break;
        }
    }
}
?>
<p>please enter a name</p>
<form method="post">
    <input name="name" type="text">
    <input type="submit" value="go!">



Aucun commentaire:

Enregistrer un commentaire