Hi I have looked at other posts about this but they are 2 or more years old so I thought it was better to start fresh.
As the title suggests I am trying to make a login
Lets say your text file looks something like this:
pete|petepass|pete@somesite.com|Pete Enterprizes
john|johnpass|john@somedomain.com|John Corporation
Your code can read something like this:
$userN = $_POST['user-name'];
$passW = $_POST['pass-word'];
$userlist = file ('users.txt');
$email = "";
$company = "";
$success = false;
foreach ($userlist as $user) {
$user_details = explode('|', $user);
if ($user_details[0] == $userN && $user_details[1] == $passW) {
$success = true;
$email = $user_details[2];
$company = $user_details[3];
break;
}
}
if ($success) {
echo "
Hi $userN you have been logged in.
";
} else {
echo "
You have entered the wrong username or password. Please try again.
";
}