Fscore/objects/Users.php
/**
     * Verifica se um email existe na tabela de utilizadores
     * @return boolean
     */
Verifica se um email existe na tabela de utilizadores
@return boolean
Verifica se um email existe na tabela de utilizadores @return boolean
public function emailExists() {
        $query = "SELECT id, username, password,photo_user
            FROM " . $this->table_name . "
            WHERE email = ?
            LIMIT 0,1";
        $stmt = $this->conn->prepare($query);
        $this->email = filter_var($this->email,FILTER_SANITIZE_EMAIL);
        $stmt->bindValue(1, $this->email);
        $stmt->execute();
        $num = $stmt->rowCount();
        if ($num > 0) {
            $row = $stmt->fetch(PDO::FETCH_ASSOC);
            $this->id = $row['id'];
            $this->username = $row['username'];
            $this->password = $row['password'];
            $this->photo_user = $row['photo_user'];
            return true;
        }
        return false;
    }
public function emailExists ( ) { $ query = " SELECT id, username, password,photo_user
            FROM  " . $ this -> table_name . " 
            WHERE email = ?
            LIMIT 0,1 " ; $ stmt = $ this -> conn -> prepare ( $ query ) ; $ this -> email = filter_var ( $ this -> email , FILTER_SANITIZE_EMAIL ) ; $ stmt -> bindValue ( 1 , $ this -> email ) ; $ stmt -> execute ( ) ; $ num = $ stmt -> rowCount ( ) ; if ( $ num > 0 ) { $ row = $ stmt -> fetch ( PDO :: FETCH_ASSOC ) ; $ this -> id = $ row [ 'id' ] ; $ this -> username = $ row [ 'username' ] ; $ this -> password = $ row [ 'password' ] ; $ this -> photo_user = $ row [ 'photo_user' ] ; return true ; } return false ; }
Verifica se um email existe na tabela de utilizadores
 @return boolean
Verifica se um email existe na tabela de utilizadores @return boolean
// query to check if email exists // prepare the query // sanitize // bind given email value // execute the query // get number of rows // if email exists, assign values to object properties for easy access and use for php sessions // get record details / values // assign values to object properties // return true because email exists in the database // return false if email does not exist in the database