Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- the class:
- class User {
- var $userID,
- $userName,
- $userPassword,
- $host,
- $dbUser,
- $dbPassword,
- $dbTable,
- $dbName;
- function User(){
- $this->dbUser = 'OOP';
- $this->dbPassword = 'xxxxx';
- $this->dbName = 'OOP';
- $this->dbTable = 'usersExample';
- $this->host = 'localhost';
- }
- function registerUser($userName, $userPassword){
- $link = mysql_connect($this->host, $this->dbUser, $this->$dbPassword);
- if(!$link){
- die('Could not connect: ' . mysql_error());
- }
- else {
- echo 'Connected';
- }
- mysql_close($link);
- }
- test.php
- include('class_user.php');
- $test = new User;
- $user = 'Craig';
- $pass = 'yoyo';
- $test->registerUser($user, $pass);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement