Thanks for the second link waterssaz. That is what I'm trying to achieve.
Though my file to read from will have many different usernames and passwords, how do I differentiate between each username and password combo?
This is my login page currently, you're only able to log in if you enter the 'testuser' '123456' combo.
<?php
$username=$_POST['name'];
$password=$_POST['password'];
if($username=="testuser" && $password=="123456")
{
$_SESSION['user']=$username;
echo "Well done you have logged in as ".$_SESSION['user'];
echo "<br/><a href='guestbook.php'>Click here to go to the homepage</a> ";
echo ('<meta http-equiv="Refresh" content="3;url=guestbook.php" />');
}else{
echo "<br/><a href='loginpage.php'>Click here to go to back and try again</a>";
}
?>
My register process page is this:
$username=$_POST['name'];
$password=$_POST['password'];
$data = "$username | $password \n";
{
$file = "registerdetails.txt";
if (!$file_handle = fopen($file,"a+"))
{
echo "Cannot open file";
}
if (!fwrite($file_handle,($data)))
{
echo "Cannot write to file";
}
fclose($file_handle);
echo ('<br /><br /><center><div style="background:#ffffff url(ok.jpg) no-repeat left;">You have successfuly registered.<br />Please log in.</div></center>');
echo ('<meta http-equiv="Refresh" content="2;url=loginpage.php" />');
The data is being recorded in my txt file after it has been entered to the register page, I need to use this data to log in.
Thanks all for the help, the links are helping