Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. the class:
  2.  
  3. class User {
  4.  
  5. var $userID,
  6. $userName,
  7. $userPassword,
  8. $host,
  9. $dbUser,
  10. $dbPassword,
  11. $dbTable,
  12. $dbName;
  13.  
  14. function User(){
  15.  
  16. $this->dbUser = 'OOP';
  17. $this->dbPassword = 'xxxxx';
  18. $this->dbName = 'OOP';
  19. $this->dbTable = 'usersExample';
  20. $this->host = 'localhost';
  21.  
  22. }
  23.  
  24. function registerUser($userName, $userPassword){
  25. $link = mysql_connect($this->host, $this->dbUser, $this->$dbPassword);
  26. if(!$link){
  27. die('Could not connect: ' . mysql_error());
  28. }
  29. else {
  30. echo 'Connected';
  31. }
  32. mysql_close($link);
  33. }
  34.  
  35. test.php
  36.  
  37. include('class_user.php');
  38.  
  39. $test = new User;
  40.  
  41. $user = 'Craig';
  42. $pass = 'yoyo';
  43.  
  44. $test->registerUser($user, $pass);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement