0

I'm new at this site, and at programming too. The thing is that I am trying to do a login page and it doesnt work. I dont get any error message it just doesnt login even if I put the right login.

$db = new mysqli('localhost', 'root', '', 'test');

$sqli = " SELECT * FROM members WHERE username = $user AND password = $pass ";

if(!$result = $db->query($sqli)){
    die('There was an error running the query [' . $db->error . ']');
}

$check_user = mysqli_num_rows($result);

if($check_user>0){

    echo "Te has conectado";
} else {

    echo "Vuelve a intentarlo";
}

Thanks for helping :)

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
alexandgu
  • 1
  • 1
  • Show the HTML you are using for the `
    ` and its input fields. _Edit your question, dont add this as a comment_ As you are not getting the user and password from either the $_POST or $_GET arrays. There area few other obvious issues but lets start with that one
    – RiggsFolly Oct 29 '15 at 22:01
  • 1
    Encapsulate $username and $password by single quotes within the sql string. – Shadow Oct 29 '15 at 22:03
  • You are also mixing Proceedural and OO `mysqli_` thats not a good idea – RiggsFolly Oct 29 '15 at 22:05
  • Is your PHP setup with error reporting? Try adding this to the top of your script so you can see an error message at least. `````` – SacWebDeveloper Oct 29 '15 at 22:12

0 Answers0