I'm trying to create a very simple login for only one or two users, the username and password are stored in "admin.txt" the text file is formatted like: username password __ I cannot seem to have the username and password register... Thanks for the help!!
// username and password sent from form
$myusername=$_POST['username'];
$mypassword=$_POST['password'];
$sql = fopen("../admin8183/users/admin.txt", "r");
while (!feof($sql)) {
$myusername = fgets($sql);
$mypassword = fgets($sql);
$line = fgets($sql);
$myusername = trim($myusername);
$mypassword = trim($mypassword);
}
// counting rows
$admin=count(file("../admin8183/users/admin.txt"));
if($admin==1){
// Register $myusername, $mypassword and redirect to file "sendmessage.php"
session_register("myusername");
session_register("mypassword");
header("location:sendmessage.php");
}
else {
echo "Wrong Username or Password";
}
p.s. I am sure that there are a few things wrong with my code, and that there are more efficient ways of accomplishing my goal, this is my first stab at creating a login in php... Thanks for your help!
$sqlis a very misleading variable name here...