I'm having trouble, see the code I made:
<?php
class banco {
public function __construct() {
$banco_hostremoto = "127.0.0.1";
$banco_hostname = "localhost";
$banco_usuario="root";
$banco_passwd="";
$banco_nome="flptrevisan";
$conn = mysql_connect($banco_hostname,$banco_usuario,$banco_passwd);
if (!mysql_ping($conn)) { $FORADOAR = TRUE; }
else if (mysql_ping($conn)) {
$FORADOAR = FALSE;
$conexao = new mysqli($banco_hostname,$banco_usuario,$banco_passwd,$banco_nome);
}
}
public function signIn($email,$senha) {
$this->conexao->query("SELECT * FROM usuarios WHERE email = '$email' AND senha = '$senha'");
if ($sql->num_rows==1){
while($linha = $sql->fetch_array()) {
$usuario = $linha['nome'];
$acessos = $linha['acessos']+1;
}
$ip=$_SERVER["REMOTE_ADDR"];
$sql = $conexao->prepare("UPDATE usuarios SET acessos = ?, ip = ? WHERE email = ?");
$sql->bind_param('iss',$acessos,$ip,$email);
$sql->execute();
$_SESSION["autenticado"]=$email;
$_SESSION["usuario"]=$usuario;
header('location:index.php');
}
else {
echo '<div class="alertaIndexMSG">O usuário ou senha inserido é inválido(a)</div>';
}
}
}
Give the following error:
Notice: Undefined property: bank :: $ connection in C: \ htdocs \ NetBeansProjects \ flptrevisan \ classes \ connection.class.php on line 20
Fatal error: Call a member function query () on a non-object in C: \ htdocs \ NetBeansProjects \ flptrevisan \ classes \ connection.class.php on line 20
Line 20 is:
$ this-> connection-> query ("SELECT * FROM users WHERE email = '$ email' AND password = '$ password'");