the code display returned values , and if greater 1 return "yes". having trouble clause in $check. when take out code works fine when add it, page returns incorrect values. ideas what's wrong?
<?php $con = mysqli_connect("127.0.0.1","root","","lian"); $u= $_get['username']; $pw = $_get['password']; $check = "select username,password users username='$u' , password='$pw'"; $login = mysqli_query($con,$check) or die(mysqli_error($con)); $num_rows = mysqli_num_rows($login); echo "$num_rows \n"; if (mysqli_num_rows($login) == 1) { $row = mysqli_fetch_assoc($login); echo 'yes'; exit; } else { echo 'no'; exit; }
leaving aside injection vulnerabilities, may because of special characters or whitespace. try trim'ing values.
$u = trim($_get['username']); $pwd = trim($_get['password']); are getting number of results 0? try echoing statement in development environment check statement is.
Comments
Post a Comment