php - This basic login form is not doing anything -


i have edited code answers far getting these errors

warning: mysqli_num_rows() expects parameter 1 mysqli_result, boolean given in c:\xampp\htdocs\test\index.php on line 18

warning: mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given in c:\xampp\htdocs\test\index.php on line 28

line 18 - $checkuser= mysqli_num_rows($query);

line 28 - while ($row = mysqli_fetch_array($query)) {

can shed light on please

 <?php    require_once('config.php');     if(isset($_post['login']) && isset($_post['uname']) && isset($_post['pass1'])) { // here check if input sent   $uname = $sql-> real_escape_string($_post['uname']); $pass1 = $sql-> real_escape_string($_post['pass1']);    if ( !empty($uname) && !empty($pass1)) {   // check if input not empty    $query= mysqli_query($sql, "select uname, pass1 login uname='$uname'");   $checkuser= mysqli_num_rows($query);     if($checkuser != 1) {      $error = "username doesn't exist in our database!";   }    // change $login $query   while ($row = mysqli_fetch_array($query)) {    $checkpass= $row['pass1'];      // here changed $pass1 $checkpass    if ($pass1 == $checkpass) {       setcookie("user", $uname, time()+7200);     $_session['user'] = $uname;     $_session['start'] = time();     $_session['expire'] = $_session['start'] + (60 * 60 * 60);     header("location: main.html");     exit();    } else {       $error = "incorrect password!";    }   }  } else {   $error = "please enter username , password.";  } }    ?> 

<input type="button" value="login" name="login" />  

needs

<input type="submit" value="login" name="login" />  

or

<button type="submit" name="login">login</button> 

the way had require javascript in order have form submit upon clicking button.

unless have other mechanism of submitting form, why form not submitting. other that, need more specific issues have.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -