0
ted_chou12's Avatar, Join Date: Nov 2006
Go4Expert Member
can you write an eg. and send the file to me with zip?
0
ted_chou12's Avatar, Join Date: Nov 2006
Go4Expert Member
i just want a simple example. With the username and age in the text file and the codes that you have to include in the php page, thanks so much.
0
ted_chou12's Avatar, Join Date: Nov 2006
Go4Expert Member
spiderman, you not there...? HELP ASAP
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Try this out, hope you got the point!

Code: PHP
<?
/*
**  Our text file's format is values separated by #
**  And example entry would look like this
**  pradeep#myPassword#Kolkata
*/


$TEXT_FILE = 'data.txt';
$aData = @file($TEXT_FILE); // collect all data into an array

// Dummy data
$user = 'pradeep';
$pwd = 'g4e';

foreach($aData as $v)
{
    list($u,$p,$c) = explode("#",$v); // split up the differnt parts of the data

    if($u == $user && $p == $pwd)
    {
        print "Matched";
        break;
    }
}

?>

Sample text file:
Code:
pradeep#g4e#Kolkata
shabbir#G4E#Kolkata
manindar#ABC#Mumbai
0
ted_chou12's Avatar, Join Date: Nov 2006
Go4Expert Member
hey, thanks a lot. it finally worked
0
ted_chou12's Avatar, Join Date: Nov 2006
Go4Expert Member
hi, again.
As i got this to work, things got more complicated, here
PHP Code:
<?php
$bData 
= @file("../admin/log_files/members_list.txt"); 
foreach(
$bData as $w){list($username1,$username2,$username3) = explode(":",$w);
$aData = @file("../admin/log_files/members_list.txt"); // collect all data into an array
foreach($aData as $v){list($username,$email,$time) = explode(":",$v); // split up the differnt parts of the data?
echo "<table><tr><td><font face=\"arial\" size=5><b>Last Modification:</b></td><td>$username</td></tr></font>";
echo 
"<tr><td><font face=\"arial\" size=5><b>Name:</b></td><td>$email</td></tr></font>";
echo 
"<tr><td><font face=\"arial\" size=5><b>Gender:</b></td><td>$time</td></tr></font></table>";}}
?>
Now I have two layers, I separated each username with # and the user data with :, and i want to ask if the "$username1,$username2,$username3..." part streches to infinity, what shall i put in?
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Code: PHP
<?
// Simple just do this
$aUserList = explode("#",$v);
// This returns an array
?>
0
ted_chou12's Avatar, Join Date: Nov 2006
Go4Expert Member
oh, so you dont separte the data?
0
ted_chou12's Avatar, Join Date: Nov 2006
Go4Expert Member
Can you give me another example please?
I cant get it to work
ps. please do include the txt file as well, a big "pre"thanks!
0
cyberience's Avatar, Join Date: Dec 2006
Newbie Member
Good script, got a question though, if we have multiple servers with various configurations in load balancing, and we try to maintain a session, that session will be lost when either round robin on next connection is in effect, so sessions is not an option due to persistence issues, and we don't want to enable persistence through the firewall, as it is not under our control. so we would need to rely on the cookie credentials for every page call to validate the user log in!
also, due to distributed database architecture, we can not maintain credentials in the database either. So we would need to take the cookie credentials and validate on every page. and pass other data via http header.

What is the modification to this script if sessions are not available, but still maintain security?