View Full Version : Add a sign-up feature to a flat file login script

10-22-2009, 02:23 PM
Good day to you all,
I'm working on a flat file login script and I would like to add a sign-up feature to it with a email confirmation process.

Here is my code :

//sessions must be initialized prior to any output if output buffering if off

//the list of files containing passwords
$files = array(

//if list of users not set create a new array
$_SESSION['users'] = array();

if(isset($_POST['username']) && isset($_POST['password'])){

//need to remove slashes from POST if magic_quotes are on
$_POST['username'] = stripslashes($_POST['username']);
$_POST['password'] = stripslashes($_POST['password']);

$userFound = false; //we need this to exit the loops
foreach($files as $file){ //loop every file in the $files array
if($fh = fopen($file, "r")){
while(!feof($fh) && !$userFound){ //while not the end of the current file or the user was not found
list($username, $password, $url) = explode(",", fgets($fh,1024));

if(($username == $_POST['username']) && ($password = $_POST['password'])){
$_SESSION['username'] = $username;
$_SESSION['present'] = true;
$_SESSION['legal'] = true;
$_SESSION['profile'] = $username.".txt";
array_push($_SESSION['users'], $username); //add the current user to the list of users
header("Location: ".$url);
$userFound = true; //confirm that the user was found


//we need to use break to exit the foreach loop if the user is found in one of the files
} else
echo "Unable to complete";
login('Invalid Member name or Password.<br />');
} else {

function login($response='Welcome visitor !') {

the user, password and redirection path are listed like the following in the files :

user, pass, path
user, pass, path

How can I add this sign in feature, user would click on sign in, fill a form with his/her full name as user, no space, choose a password, an email would be send and there would be an link to confirm, then the user would be added to the really list.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum