Previously, we coded in PHP to check if the user is verified or not and we did this by matching his user name and password with our pre-declared user name and password.
Now we will expand this verification to three users. Yes, if any of those three users logins with their respective name and password, they will be successfully logged in. So, our HTML login page will be same that we created earlier –
<html>
<head>
<title>Untitled 1</title>
</head>
<body text="maroon">
<form action="firstand lastname.php" method="post" name="myform">
<table border="5" bordercolor="darkslategray" align="center" width="400px" >
<tr><td>UserID</td><td><input type="text" name="uid"></td>
<tr><td>PASSWORD</td><td><input type="password" name="pwd"></td>
<tr><td align="center" colspan="2"><input type="submit"
value="LOGIN" name="submit"></td></tr>
</table>
</form>
</body>
</html>
Now we have to think a logic to display the message. I have derived the following logic yours might be different.
<?php
$user = array("Randy Orton", "Lesnar", "Roman Reigns");
$passwd = array("randy", "lesnar", "reigns");
$count= 0 ;
$nm = " ";
extract($_POST);
if (isset($submit))
{
for($i=0 ; $i<3 ; $i++)
{
if (strcmp($user[$i],$uid)==0 && strcmp($passwd[$i],$pwd)==0)
{
$count=1;
$nm = $uid ;
break;
}
}
if($count==1)
echo "Welcome $nm, You are successfully logged in.";
else
echo "Invalid Username or Password";
}
?>
Remember that it is not compulsory to make two different files. We can embed both the codes in one single PHP file store it in www and run it. But it is better to keep your designing part and logic part separate in HTML and PHP files respectively.
That’s it.
Have ERROR FREE coding!

