View Single Post
  #5 (permalink)  
Old 17-10-2007, 08:49 PM
LeadMagnet's Avatar
LeadMagnet LeadMagnet is offline
Mr. Tambourine Man
 
Join Date: Jun 2007
Location: Ireland
Gender: Male
Posts: 1,715
Default

I have a headache so i'm not going to do much for you on this right now. But this should be enough to get you started in the right direction:


names.php =
PHP Code:
<?php
$passwords
["David"] = "danjz.sL9bgaQ";
$passwords["Admin"] = "daguOy8u.JOqY";
?>
login.php =
PHP Code:
<?php
include 'names.php';
print_r($passwords);
?>
You get the idea anyway.
Your admin form should modify the names.php file to add a new line like i've written above for each new user. Simple enough script.
Your names.php is then read in as an array already with the username as the key and the password as the corresponding value for each key.

You've got the wrong idea of an include.



Here's an example:

Take the 2 files above (names.php and login.php).
a (half) processed version of login.php looks like this right after the include is performed:

PHP Code:
<?php
$passwords
["David"] = "danjz.sL9bgaQ";
$passwords["Admin"] = "daguOy8u.JOqY";
print_r($passwords);
?>
If login.php included the names.txt file like you've created above, it would look like this

PHP Code:
<?php
"David" => "danjz.sL9bgaQ""Admin" => "daguOy8u.JOqY",
print_r($passwords);
?>
And what the hell is that as far as php is concerned? That's just a load of mumbo jumbo. ('"David" equal to or greater than "danjz.sL9bgaQ", "Admin" which is equal to or greater than "daguOy8u.JOqY",print_r($passwords);' er... ok... Computer says no! )

You get the picture.
__________________
Subtlety is my middle name... and first and last in case you didn't get the point.
Reply With Quote