javascript - PHP/MySQL Query Issues -


i attempting set basic log in system website having major issues getting query operate correctly. far have tried figure out going on has failed. far can tell query not failing not returning data either. using query in phpmyadmin results in proper query information being returned.

here php code:

<?php  //empty error variables $sqlerror;  if(empty($_post['uname'])) {     $data = "false,username field empty";     echo json_encode($data);     return false; }  if (empty($_post['pword'])) {     $data = "false,password field empty";     echo json_encode($data);     return false; }  $username = $_post['uname']; $password = $_post['pword'];  echo $username."<br/>";  echo $password."<br/>";  if(!checkdb()) {     $data = "false,".$sqlerror;     echo json_encode($data);     return false; }  else {     checkdbl(); }  function checkdb() {     echo "made checkdb! <br/>";     $connection = mysqli_connect("xxxx","xxxx","xxxx","xxxx");      if(mysqli_connect_errno())     {            $sqlerror = "could not log in database";         return false;     }      echo "connection established! <br/>";     mysqli_close($connection);     return true;     }  function checkdbl($username,$password) {     echo "made checkdbl! <br/>";     $sql =  mysqli_connect("xxxx","xxxx","xxxx","xxxx");      if(mysqli_connect_errno())     {         echo "connection failed";         return false;     }    if ($query = mysqli_prepare($sql,"select password login_info username = ?"))     {         mysqli_stmt_bind_param($query, "s", $username);          if (!mysqli_stmt_execute($query))         {             echo "query failed! <br/>";              echo mysqli_error($sql);             return false;         }          else         {             echo "query successful <br/>";         }          mysqli_stmt_bind_result($query,$password2);         mysqli_stmt_fetch($query);            echo "the password is: ".$password2;     }      else     {         echo "statement preparation failed <br/>";     } } ?> 

and output in browser code:

gwil

testpassword

made checkdb!

connection established!

made checkdbl!

query successful

the password is:

$connect = mysqli_connect("localhost","root","","database") or die (mysqli_error($connect)); mysqli_set_charset($connect,"utf8");  $username="hej";  if ($query = mysqli_prepare($connect,"select password login_info username =?")){  mysqli_stmt_bind_param($query, "s", $username);      if (!mysqli_stmt_execute($query)){      echo "query failed! <br/>";      echo mysqli_error($query);     return false;     }else{     echo "query successful <br/>";     } mysqli_stmt_bind_result($query,$password2);<br/> mysqli_stmt_fetch($query);<br/> echo "the password is: ".$password2;<br/> }else{ echo "statement preparation failed";} 

in table login_info have username=hej , password=123

this achive looking for.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -