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 Like 26 Dislike
Previous forums Next forums
Other forums

Running a cron job through PHP/Apache?!
Hello all,
I have a PHP script which makes a cron file from user input. When i try to run the cro

Login script (probably a simple error)
dbConfig.php
Code: <?
// Replace the variable values below
// with your specific dat

Two fgetcsv related questions ;D
First of im trying to get a file from a merchants server but the directory is protected, I know the

Filling gaps in dates
So i'm doing a query for sales data and my return array looks like this

('date' => '20

Multithreading in Oracle (Java, SQLJ, Pro*C,??) on 10g
I am investigating how to run a Java stored procedure in multithread mode.
I know that if I chang

Keep newlines from textarea?..
I'm creating a simple encoding program, and what I want it to do is retain the newlines, as echoing

The repetition structure: the while statement not working
New programming student, have assignment as follows:
A restaurant has 4 lunch combos for custom

Google Wave
So... has anyone used it yet? Is it any good?

http://wave.google.com/help/wave/about.html#vid

why preg_match_all does not return the number of matches
My regex looks like

X[^x{4e00}-x{9fa5}]*Y

(where X and Y are two Chinese characters)

Keeping track of php uploads
Hello all.

I was looking at the way PHP handles file uploads.
It seems that PHP uses a tem

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash