WSparrow Posted December 30, 2010 Share Posted December 30, 2010 Hi all, I'm building a site with session based logins. I'm trying to setup a php file like the following: <?php $users = array( "username" => "password", "anothername" => "theirpass" ); ?> The idea being that this file can be called and the login can be validated with array_key_exists. But how do I setup that php file so that new users are automatically added when they register? And yes I admit I'm a noob. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/223035-self-propagating-arrays/ Share on other sites More sharing options...
BlueSkyIS Posted December 30, 2010 Share Posted December 30, 2010 you'll need to store the usernames and passwords some way; either in a text file or in a database. Quote Link to comment https://forums.phpfreaks.com/topic/223035-self-propagating-arrays/#findComment-1153146 Share on other sites More sharing options...
Maq Posted December 30, 2010 Share Posted December 30, 2010 Why don't you use a database? Quote Link to comment https://forums.phpfreaks.com/topic/223035-self-propagating-arrays/#findComment-1153155 Share on other sites More sharing options...
WSparrow Posted December 30, 2010 Author Share Posted December 30, 2010 I'm using MySQL to aquire and store all the user account data. Where I'm having trouble is figuring out how to load it into a php file without having to do it manually many times a day. However, if you know of a better way to setup session based logins, I'm open to suggestions. Quote Link to comment https://forums.phpfreaks.com/topic/223035-self-propagating-arrays/#findComment-1153170 Share on other sites More sharing options...
BLaZuRE Posted December 31, 2010 Share Posted December 31, 2010 Why are you trying to use a file? Why not use a database? You're essentially replicating the function of a database by using a file instead, though with less efficiency and more time invested in it. Quote Link to comment https://forums.phpfreaks.com/topic/223035-self-propagating-arrays/#findComment-1153219 Share on other sites More sharing options...
Anti-Moronic Posted December 31, 2010 Share Posted December 31, 2010 Don't know why nobody has laid this out fro you instead of pointing out the obvious or asking questions you clearly will not understand. Trouble here is that you should be using a database. $users = array() should be $users = mysql_query() which will then query the database for the user. You need to read up on some basic user management, mysql, and sessions in php: http://www.wikihow.com/Create-a-Secure-Login-Script-in-PHP-and-MySQL It's quite simple stuff but what is more important right now is that you see how you are approaching this is fundamentally wrong. Quote Link to comment https://forums.phpfreaks.com/topic/223035-self-propagating-arrays/#findComment-1153225 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.