Welcome to Dream.In.Code
Become a PHP Expert!

Join 137,431 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,903 people online right now. Registration is fast and FREE... Join Now!




A class to authenticate a regular user

 
Reply to this topicStart new topic

A class to authenticate a regular user

thiago.de.lima
22 Jan, 2008 - 11:47 AM
Post #1

New D.I.C Head
*

Joined: 8 Jan, 2008
Posts: 4

Hi, guys

It's my class

CODE

class auth{
     public  $username; $password; $connection; $database; $firstname;
     public  $permission = array();

     public function auth(){
          require('adodb.inc.php');
          $this->database = NewADOConnection($driver);
          if($this->database){
                  $this->connection = $this->database->Connection($host,$user,$pass,$db);
                   if($this->connection){
                           return $this->database;
                   }
          }
      }      
     public function __setName($username){
             $this->username = $username;
     }
     public function  __getName($username){
           return $this->username;
     }
      public function __setPass($password){
             $this->$password = $password;
     }
     public function  __getPass($password){
           return $this->$password;
     }
     public isValid(){
           if($this->db->Execute('SELECT name FROM user WHERE user = '.$this->username)){
               return true;
     }


}


What should I do to design this class better?
If I use the singleton pattern to check if I have a instance of adodb and retrieve that, would the connection still be opened?
I want to use just one connection to do transactions with the database to all other classes
How do I implement that?
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: A Class To Authenticate A Regular User
22 Jan, 2008 - 11:49 AM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,550



Thanked: 67 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(thiago.de.lima @ 22 Jan, 2008 - 12:47 PM) *

What should I do to design this class better?

MD5 hash the password. Plain text passwords are bad.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/5/08 04:58AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month