Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class access {
- var $host = null;
- var $user = null;
- var $pass = null;
- var $name = null;
- var $conn = null;
- var $result = null;
- function construct($dbhost , $dbuser , $dbpass , $dbname){
- $this->host = $dbhost;
- $this->user = $dbuser;
- $this->pass = $dbpass;
- $this->name = $dbname;
- }
- public function connect() {
- $this->conn = new mysqli($this->host , $this->user , $this-> pass , $this->name);
- if(mysqli_connect_error()){
- echo 'could not connect database';
- }else{
- echo 'Connected and select';
- }
- $this->conn->set_charset("utf8");
- }
- public function disconnect(){
- if($this->conn != null){
- $this->conn->close();
- }
- }
- public function registerUser($email , $password , $salt , $fullname , $phone) {
- $sql = "INSERT INTO `users` SET `email`=?, `password`=? ,`salt`=?, `fullname`=?, `phone`=?";
- $statement = $this->conn->prepare($sql);
- if(!$statement){
- //throw new Exception($statement->error);
- try{
- throw new Exception("error");
- } catch (Exception $e){
- echo $e->getMessage();
- }
- }
- $statement->bind_param('sssss', $email, $password, $salt, $fullname, $phone);
- $returnValue = $statement->execute();
- return $returnValue;
- }
- public function selectUser($email){
- $sql = "SELECT * FROM users WHERE email='".$email."'";
- $result = $this->conn->query($sql);
- if($result != null && (mysqli_num_rows($result) >= 1)){
- $row = $result->fetch_array(MYSQLI_ASSOC);
- if(!empty($row)){
- $returnArray = $row;
- }
- }
- return $returnArray ;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement