Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/223035-self-propagating-arrays/
Share on other sites

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.