I have been making a website that has a user-account-loggin system that is based on accessing .txt files in php. I originally tested much of the code on a free web-hosting service and got the user-account-loggin system functional, but when I tried to move it over to my own personal apache web server the functionality of some of my php code seems to have been lost and I'm not sure why. Specifically, I have narrowed it down to the splfileobject() function returning no value for the variable $passfile. Am I missing some php library that is necessary to do this? When I looked it, up it said that php7.0 had splfileobject(), and its other connected functions, as part of the standard php library.
Here is some of my code
<?php
$username = $_POST["username"];
$password = $_POST["password"];
$account = file('usernames.txt');
$accountfix = str_replace("
", "", $account);
$filepoint = array_search($username, $accountfix);
if ($filepoint !== false) {
$passfile = new SplFileObject('passwords.txt', 'r+');
$passfile->seek($filepoint);
$potentialpass = str_replace("
", "", $passfile);
// check password
if ($password === $potentialpass) {
$_SESSION["username"] = $username;
$_SESSION["password"] = $password;
$_SESSION["loggedin"] = true;
$_SESSION["filepoint"] = $filepoint;
print "Logged in succesfully!";
}
else{
print "Incorrect Password";
}
}
else {
print "Incorrect Username.";
}
?>
For some reason opening a file like this works fine.
$account = file('textfiles/usernames.txt');
However, I want to be able to search to a specific point in a password file the has parallel data to the username file to cut down on computation time and had to use splfileobject to do so.
Thankyou