I have a text file called login.txt and I want to compare the id and password with the user's input with the one saved in the text file. I'm stuck with the php file. Any help will be appreciated.
login.txt
Brian,brianpass\n
Adam,adampass\n
Bob,bobpass\n
login.htm
<html lang="en">
<head>
<title>test</title>
</head>
<body>
<h1>Login Page</h1>
<form id="regform" method="get" action="login.php">
<p>Manager ID:<input type="text" name="mid" required="required" /></p>
<p>Password:<input type="password" name="mpassword" required="required" /></p>
<input type="submit" value="Login"/>
</form>
</body>
</html>
login.php
<?php
$mid = trim(@$_POST["mid"]);
$mpassword = trim(@$_POST["mpassword"]);
if ($mid != NULL && $mpassword != NULL)
{
$str = file("login.txt");
$newArray = array();
foreach ($str as $value)
{
$array = (explode(",", $value));
$newArray[$array[0]] = trim($array[1]);
}
}
?>
Question: I want the system to determine if the login process is successful or failed and echo it.