Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class databaseConnection {
- var $host;
- var $username;
- var $password;
- var $database;
- var $connect;
- function __construct($host, $username, $password, $database) {
- $this->host = $host;
- $this->username = $username;
- $this->password = $password;
- $this->database = $database;
- }
- function setupConnection() {
- $this->connect = mysql_connect($this->host, $this->username, $this->password);
- mysql_select_db($this->database, $this->connect);
- }
- function queryDB($email, $password) {
- $email = mysql_real_escape_string($email);
- $password = mysql_real_escape_string($password);
- $this->setupConnection();
- $sql = "SELECT * FROM users WHERE email='$email' and password=sha1('$password')";
- $result = mysql_query($sql, $this->connect);
- $numberOfRows = mysql_num_rows($result);
- if($numberOfRows > 0) {
- return TRUE;
- }
- else if(!$result) {
- return FALSE;
- }
- else {
- return FALSE;
- }
- $this->closeDB();
- }
- function closeDB() {
- mysql_close($this->connect);
- }
- }
Add Comment
Please, Sign In to add comment