php - Form with login and password not working -


i'm trying create form login , password can not authenticate. have checked mysql query , ok. think problem comes $stmt->num_rows(); returns 0.

php form

<?require('cabecera.php');?> <!doctype html> <html>     <head>         <meta http-equiv="content-type" content="text/html; charset=utf-8">         <title>pujas</title>         <script type="text/javascript" src="jquery-1.9.1.min.js"></script>       </head>     <body>             <div id='login'>                 <input type="text" name="txtuser" id="txtuser">                 <input type="text" name="txtpass" id="txtpass">                 <input type="button" name="butconectar" id="butconectar" value="conectar">             </div>     </body>   <? if ($_session['cmensaje']!='') { ?>   <script language="javascript">      alert('<?=$_session['cmensaje']?>');   </script>   <? unset($_session['cmensaje']); ?>   <? } ?>   <script>   $("#butconectar").click(function() {         var txtuser = $("#txtuser").val();         var txtpass = $("#txtpass").val();         /*if((txtuser=='') || (txtpass=="")){             alert('hay campos sin rellenar.');         }*/          $.ajax({type: "post",                      url: "pr17login.php",                      data: "txtuser="+txtuser+"&txtpass="+txtpass,                      success:function(data) {                          alert(data);                      }         })     }) 

php check login , password

<?require('pr17conecta.php');   require('cabecera.php');   ini_set('display_errors',1); error_reporting(e_all);      $user=$_post['txtuser'];     $password=md5($_post['txtpass']);     //$query=mysql_query("         // select * tb_user username='$u' , password='$p'        // ");         $csql="select login,clave usuarios login=? , clave=?";         $stmt=$oconni->prepare($csql) or die($oconni->error);         $stmt->bind_param('si',$user,$password);         $stmt->execute();                                        $stmt->bind_result($login,$clave);         $stmt->fetch();      $row = $stmt->num_rows();     if ($row == 1){         session_start();         $_session['txtuser']=$login;         header("location: pr17pujas.php");     }else{         //header("location: pr17login.php");             echo 'usuario o contraseña inválidos.';     } ?> 

cabecera.php

    <? @header('content-type:text/html; charset=utf-8');    session_start();    define('max_idle_time', 3);    ?> 

num_rows property, not method, of mysqli result.

you need retrieve using $stmt->num_rows not $stmt->num_rows().


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -