Jump to content
Fórum Script Brasil
  • 0

Estou com um baita erro no meu código aqui



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");
        if ($sql->rowCount() > 0) {
            return false;
            $sql = $pdo->prepare("INSERT INTO usuarios (nome, email, senha) VALUES (:n, :e, :s)");
            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));     //<----------
        if($sql->rowCount() > 0){
            $dado = $sql->fetch();
            $_SESSION ['id_usuario'=$dado['id_usuario'];
            return true//a pessoa esta logado
            return false//n foi possivel logar
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.

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
    • Total Posts
  • Create New...