Hi I am newbie on this forum, I join here coz I know I want to learn oop in php and also meet new people.

I am desperately want to learn oop approach, Im a web developer for 3 years now but still using procedural approach.. Please if anyone is interested to answer my questions or to share their knowledge it would really appreciated..

I dont know where to start, I read a lot of articles in oop, but I really find it difficult to understand.. I feel like I am really behind..

I want to learn from the basic, like from connecting to database to querying the data.

for now, Im going to make a simple login page using oop, I already have a code in connecting to the database which I also got this from other resources.


class MySqlConnect {

//Variable Declatiation
private $username;
private $password;
private $host;
private $dbname;

//constructure
public function __construct($user, $pass, $host, $database){
    $this->username= $user;
    $this->password = $pass;
       $this->host = $host;
       $this->dbname = $database;

       //Make the Connection
       $connection = @mysql_connect ($host, $user, $pass) OR die ('Could not connect to MySQL: ' . mysql_error() );
    if($connection) {
        $db= mysql_select_db($database);
        if(!$db) echo "Failed to select $database";
    } 
        else {
            echo "Failed to connect to the database";
            }
}
}

thats the code for mysql connect.. and I want to have a login page

thank you..

    hey so what seems to be the problem?

    i used a book, which went through php and how to use the class concepts in web development, its called

    php and mysql web development

    fourth edition

    willing thompson

    addison
    wesley

    i found it really helpful

      Write a Reply...