Creating an PHP Auth System

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
etorvinen
-


Joined: 02 Jan 2005
Posts: 31

PostPosted: Sun Dec 03, 2006 1:04 am    Post subject: Creating an PHP Auth System Reply with quote

I am tring to create a authencation file using php, the goal is to create a php file manager that supports mutiple users, and maybe I can intergrate my databases together.
Here is what I have so far:
Code:

$host = "localhost";
$user = "sqlusername";
$pass = "sqlpassword";
$db     = "database";
$table_name = 'tblUsers';
$ms = mysql_pconnect($host, $user, $pass);
if ( !$ms )
   {
   echo "Error connecting to database.\n";
   }
mysql_select_db($db);
$query  = "SELECT * FROM $table_name ORDER BY id ASC";
$result = mysql_query($query);
while($row = mysql_fetch_row($result))
{
$id = $row[0];
$username = $row[1];              /* The username. Case sensitive. */
$password = $row[2];              /* The password. Case sensitive */
$dir = "~$username";
}

The code works well if you have one user added to the database, when you create a second it uses the last user you created.

ex: user1 and user2 are in database
if you type user1 it will come access denied if you use user2 it will go through.

I am trying to figure out how to let it search all user fields.
_________________
;@
Back to top View user's profile Send private message
olly86
-


Joined: 25 Apr 2003
Posts: 993
Location: Wiltshire, UK

PostPosted: Sun Dec 03, 2006 2:16 am    Post subject: Reply with quote

$query = "SELECT * FROM $table_name WHERE username = 'varible from user' ORDER BY id ASC";

you need to select the record matching the username that the siteuser entered on the login page. to do this you need to add a WHERE clause. (eg: WHERE username = 'varibleUsername'
_________________
Olly
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group