-------- This question has not been fully answered. Please help me! --------
Hello. I have a php login page that calls a function to determine if the username and password is correct. it is working great, but now i want to move the function, called authenticate, to an external file, so i can have one place to store my usernames and passwords. i will post the script i am using:
[PHP]<?php
session_start();
echo('<html><head><title>Login</title></head><body>') ;
if(!isset($_SESSION['userid']))
{
if(!isset($_POST['username']) || !isset($_POST['password']))
{
echo('please login. <from method="post">Username: <input type="text" name="username" /> Pasword: <input type="password" name="password" /><input type="submit" value="Login" /></form>');
}
else if(authenticate($_POST['username'], $_POST['password']))
{
$_SESSION['userid'] = $_POST['username'];
echo('<script>window.location="thispage.php";</script>');
}
}
else
{
You have logged in.
}
//this is the finction with the usernames and passwords...
function authenticate($u, $p)
{
if($u == "admin" && $p == "password") return true;
if($u == "guest" && $p == "fish") return true;
return false;
}
echo('</body></html>');
?>[/PHP]
i want to get the function above seperated into another file, so if i use this login script on another page i dont need to go and update the usernames in EVERY page. Your help is greatly appreciated.