But the problem is, I'm not sure how to form the loop. I tried looping the entire if-else block, but the if statements seem to not work and the text output is displaying 3 times.
Also, I know that some methods besides using loop will be easier, but we're asked to make a simple loop statement since we haven't discussed beyond that topic yet.
<html>
<head>
<title>LOGIN</title>
</head>
<body>
<center>
<h1>LOGIN</h1>
<form action="" method="post">
<table>
<td>
Name: <input type="text" name ="Name"><br><br>
Password: <input type="password" name="Pass"><br><br>
<center>
<input type="Submit" value="OK" name="okay">
<input type="reset" value="Clear">
</td>
</table>
< /form>
</body>
</html>
<?php
$n = $_POST['Name'];
$p = $_POST['Pass'];
if (isset($_POST['okay'])) {
$ctr=1;
while ($ctr<3){
if(empty($p) || empty($n)){
echo "You have to fill in all the forms!";
exit;
}
else if ($n=="kiel" && $p=="kiel"){
echo "Welcome " .$n. "!";
break;
}
else
$ctr++;
}
echo "Go away hacker";
}
?>

New Topic/Question
Reply




MultiQuote




|