Link to home
Start Free TrialLog in
Avatar of DaveHope
DaveHope

asked on

Flatfile login system.

Hello all, i'm making the move from ASP to PHP, especially since I moved from window to linux. Anyway, I'm looking at writing a flat-file login system, unfortunatley, i'm stumped.  The actual login data file would look like this:

[USER=Dave]
PASSWORD=password
DATA=0
OTHERDATA=0
HOMEPAGE=http://localhos

and then the next user and so on and so forth. So far, i'm reading each user into an array, like so:

<?php
$filename = "accounts";
fclose(fopen($filename,"r"));
$struser = explode("[USER=",fread(fopen($filename,"r"), filesize($filename)));

echo $struser[1];
echo "<br />";
echo $struser[2];
?>

The next step, I guess, would be to get the line "PASSWORD=" and see if it corresponds to the relevant username entered into the form. This is where I loose it ;P, any help would be GREATLY appreciated!
Avatar of mwillbanks
mwillbanks

$handle = fopen($filename,"r");
$struser = explode("\n", $handle);
fclose($handle);

try something like this
ASKER CERTIFIED SOLUTION
Avatar of shmert
shmert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DaveHope

ASKER

Thanks VERY much, I dont think i'd have ever got that by myself!