Ok, Im having some problem with this php program… It is supposed to act as a login screen. When register is clicked, the program will store whats in the username and password textbox in a .txt file, the problem is, it stores it in the .txt file but it doesnt go onto a new line. “\n” doesnt work. And when login is selected it also gives an error. Please help
$filel=“accounts.txt”;
$fhandle = fopen($filel, “a”) or die(“file cannot be opened”);
if(isset($_POST[‘register’])){
$name= $_POST[‘username’];
$password= $_POST[‘pass’];
fwrite($fhandle, $name."\n" .$password. “\n”);
}
fclose($fhandle);
//++++++++ word
if(isset($_POST[‘login’])){
$name= $_POST[‘username’];
$password= $_POST[‘pass’];
Login();
}
function login(){
$name = " “;
$array = explode(”\n", file_get_contents(‘accounts.txt’));
if(isset($_POST[‘login’])){
$name= $_POST[‘username’];
$password= $_POST[‘pass’];
for($i=0; $i< 4; $i=$i+2){
$ii=$i+1;
if($name == $array[$i] && $password == $array[$ii]){
echo “Access Granted”;
}
}}}
?>
USERNAME: PASSWORD: