Jump to content
Fórum Script Brasil
  • 0

Estou com um baita erro no meu código aqui


Question

<?php
class Usuario
{
    private $pdo;
    public $msgErro = "";
 
    public function conectar($nome, $host, $usuario, $senha)
    {
        global $pdo;
        try {
            $pdo = new PDO("mysql:dbname=".$nome.";host=".$host,$usuario,$senha);
 
        } catch (PDOException $e) {
            $msgErro = $e->getMessage();
        }
    }
 
    public function cadastrar($nome, $email, $senha)
    {
        global $pdo;
        //verificar se já exista o email cadastrado
        $sql = $pdo->prepare("SELECT id_usuario FROM usuarios where email = :e");
 
        $sql->bindvalue(":e",$email);
        $sql->execute();
        if ($sql->rowCount() > 0) {
            return false;
        }
        else{
            $sql = $pdo->prepare("INSERT INTO usuarios (nome, email, senha) VALUES (:n, :e, :s)");
            $sql->bindvalue(":n",$nome);
            $sql->bindvalue(":e",$email);
            $sql->bindvalue(":s",md5($senha));
            $sql->execute();
            return true;
            
        }
 
        //caso não tenha
    }
 
    public function logar($email, $senha){
        global $pdo;
        //verificar se o email e senha estão cadastrados
 
        $sql = $pdo->prepare("SELECT id_usuario FROM usuarios WHERE email = :e AND senha = :s");
        $sql->bindvalue(":n",$nome); //<--------------
        $sql->bindvalue(":s",md5($senha));     //<----------
        $sql->execute();
        if($sql->rowCount() > 0){
            $dado = $sql->fetch();
            session_start();
            $_SESSION ['id_usuario'=$dado['id_usuario'];
            return true//a pessoa esta logado
        }
        
        else{
            return false//n foi possivel logar
 
        }
 
        //criar 
 
    }
}
    
?>
 
o erro esta dando onde esta o comentario //<-------------
Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      148719
    • Total Posts
      644508
×
×
  • Create New...