PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 22nd, 2009, 09:22 AM
Peuplarchie's Avatar
Peuplarchie Peuplarchie is offline
Stand
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Québec
Posts: 208 Peuplarchie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 11 h 52 m 43 sec
Reputation Power: 3
Post php4 - Add a sign-up feature to a flat file login script

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 :

PHP Code:
<?php
//sessions must be initialized prior to any output if output buffering if off
session_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 array
if(!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!
__________________
That's why we are not alone on earth, to help each other !
Let's build !

Reply With Quote
  #2  
Old October 22nd, 2009, 11:00 PM
GroongeIgnope GroongeIgnope is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Location: Switzerland
Posts: 1 GroongeIgnope User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 4 sec
Reputation Power: 0
Send a message via ICQ to GroongeIgnope
Message

Reply With Quote
  #3  
Old October 23rd, 2009, 07:16 AM
gaksinsasenia gaksinsasenia is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Location: Haiti
Posts: 1 gaksinsasenia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 50 sec
Reputation Power: 0
Send a message via ICQ to gaksinsasenia
Message

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > php4 - Add a sign-up feature to a flat file login script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek