i have an array of usernames and if a specific name is entered then code should say i know you concatenated with input name...this part is working fine...the problem is in if(!$knowyou)
this line of code is giving the error of undefined variable i'm not getting it i tried to resolve it by declaring variable to to top of code i.e giving variable a global scope but this doesn't solve my problem i also tried defining variable at different places but it doesn't work for me...please anyone of you can explain the solution of error?? if you have time then please tell me why this error occure so i can avoid it in future thanks in advance.
<body>
<?php
//print_r ($_GET);
//$knowyou;
$names=array("mirza","ali","usman");
if(isset($_POST['submit'])){
if($_POST["uname"]){
foreach($names as $name){
if($_POST["uname"]==$name){
echo "i know you your name is ".$name;
$knowyou=1;
}
}
if(!$knowyou){
echo "i don't know you".$_POST["uname"];
}
}
else {
echo"please enter your name";
}
}
?>
<form method="post">
<label for="uname">Name</label>
<input type="text" name="uname" />
<input type="submit" name="submit" value="Submit" />
</form>
</body>