Add a sign-up feature to a flat file login script
Posted on
16th Feb 2014 07:03 pm by
admin
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 :
Line number On/Off | Expand/Contract <?php//sessions must be initialized prior to any output if output buffering if offsession_start(); //the list of files containing passwords$files = array( "pass.txt", "test/pass2.txt", "admin/pass3.txt"); //if list of users not set create a new arrayif(!isset($_SESSION['users'])) $_SESSION['users'] = array(); if(isset($_POST['username']) && isset($_POST['password'])){ //need to remove slashes from POST if magic_quotes are on if(get_magic_quotes_gpc()){ $_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 } } fclose($fh); //we need to use break to exit the foreach loop if the user is found in one of the files if($userFound) break; } else echo "Unable to complete"; } if(!$userFound) login('Invalid Member name or Password.<br />');} else { login();}?><?php 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.
Thanks!
No comments posted yet
Your Answer:
Login to answer
116
26
Other forums
using variables in another page
I have a test database set up on localhost. I have a form that I can type a name into, hit the butto
Calling a Procedure with IN & OUT Parameters
Hello,
I usually call my procedures using the following way
declare variable e
Help a newbee save my job !
Hey guys i am dying here i am new to php and would like for someone to help me with this problem
PHP mail() returns true but doesn't work
First off I apologize if this is a newbie question, and I generally don't like asking questions that
php - xml what is the best way to do this.
IN essence I want to have a script calling the info from the database.. I have no problem thus far,
Retrieving Data from Two Different Databases
Hello All,
Ran into another problem and would appreciate some help! I have two datab
Working with Global Variables
hi, I'm not really sure why the following code is returning a "Call to a member function getBan
Dynamically set AccordianPane Header
I have an accordian on my master page. I'd like to be able to dynamically change the header on diff
More pug propaganda.
http://www.youtube.com/watch?v=8Kkrmubsgf8
The commercial is definitely worth watching pug aw
Multiple if statements
Ok so seems basic but for some reason I'm not doing it right. What I want is to be able to have 2 se