PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Is there a better way of doing it? I was thinking i could just include that on each document and it will check for one, but lets say it gets to 100 or so accounts, is there any more effecient way?
The way I would do it would be to use a database to store the usernames and encrypted passwords. You can use a PHP function like md5(). This solution will oneway encrypt the password.
Then instead of your if() statement with the usernames and passwords statically entered you can do something like this (assuming using MySQL)
[I was typing a small tutorial and then realized someone else already had ] http://www.phpcomplete.com/tutorials.ph ... adTutorial
Note that the passwords in the tutorial are not encrypted. You would need only to change the code to be something similar to the below:
(Note - I use ... as a placekeeper as the text it replaces doesn't change)
$encrypPassword = md5($password);
$query="... AND password='$encrypPassword '";
I haven't actually tested this - but I have used similar code in the past. Also note that you will need to encrypt the password when first entering the user's information into the database.
I dont have access to a mysql database... I just wanted to know if it would be better to use an array rather than a bunch of 'or' statements, but i dont know how to do an array, so if it is more effective could anyone direct me?
for look up? huh? That really didnt make much sense. If you mean for creating accounts, i already have that planned, i just want to know if i should use an array or not. what is so hard to understand?
i understand i think... try this script...
I would also put the php script in a seprate file and use the require_once() function so that you only have to edit one file when altering the users or script