Guest User

Untitled

a guest
Jan 12th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. class databaseConnection {
  2. var $host;
  3. var $username;
  4. var $password;
  5. var $database;
  6. var $connect;
  7.  
  8. function __construct($host, $username, $password, $database) {
  9. $this->host = $host;
  10. $this->username = $username;
  11. $this->password = $password;
  12. $this->database = $database;
  13. }
  14. function setupConnection() {
  15. $this->connect = mysql_connect($this->host, $this->username, $this->password);
  16. mysql_select_db($this->database, $this->connect);
  17. }
  18. function queryDB($email, $password) {
  19. $email = mysql_real_escape_string($email);
  20. $password = mysql_real_escape_string($password);
  21. $this->setupConnection();
  22. $sql = "SELECT * FROM users WHERE email='$email' and password=sha1('$password')";
  23. $result = mysql_query($sql, $this->connect);
  24. $numberOfRows = mysql_num_rows($result);
  25. if($numberOfRows > 0) {
  26. return TRUE;
  27. }
  28. else if(!$result) {
  29. return FALSE;
  30. }
  31. else {
  32. return FALSE;
  33. }
  34. $this->closeDB();
  35. }
  36. function closeDB() {
  37. mysql_close($this->connect);
  38. }
  39. }
Add Comment
Please, Sign In to add comment