Quantcast
Channel: Últimos conteúdos
Viewing all articles
Browse latest Browse all 14190

Fatal error: Call to a member function prepare() on a non-object in C:

$
0
0

Olá, estou com um erro e não consigo resolver, segue o erro e codigo:

Fatal error: Call to a member function prepare() on a non-object in C:\wamp\www\av3\usuario_login.php on line 27

<?php include('header.php'); ?>

<?php include('conexao.php'); ?>

<form method='post'>
  <label>
    E-mail:
    <input type='email' name='email' size='30' maxlength='30' />
  </label>
  <label>
    Senha:
    <input type='password' name='senha' size='30' maxlength='30' />
  </label>
  <input type='submit' value='Entrar >>>' />
</form>

<br><br>

<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  $email = $_POST['email'];
  $senha = md5($_POST['senha']);
  
  $sql = 'SELECT id_usuario, nome FROM usuarios WHERE email = ? AND senha = ?';
  
  $comando = $conexao->prepare($sql);  
  $comando->bind_param('ss', $email, $senha);
  $comando->execute();
  $comando->bind_result($id, $nome);
  
  // existe este email/senha?
  if ($comando->fetch()) {
    
    $usuario = array('id' => $id, 'nome' => $nome, 'email' => $email);
    $_SESSION['usuario'] = $usuario;
    header('Location: index.php');
  
  } else { // não existe
    echo "Usuário não encontrado. Tente novamente.";
  }
}
?>

<?php include('footer.php'); ?>

Viewing all articles
Browse latest Browse all 14190