php - How to retrieve 'id' column from entering other fields -


here code:

<?php if(isset($submit)){     require 'db/connect.php';     $sql = "select id users username='$username' , password='$password'";     $entered_user = mysql_query($sql);     $num_rows = mysql_num_rows($entered_user);      $errors = array();      if( $num_rows != 1 )     {         $errors[] = '-account not exist ';     }     elseif( $num_rows == 1 )     {         while($row = mysql_fetch_array($entered_user)){             $id = $row['id'];         }         $errors[] = 'id number --> '.$id;     } } ?> 

my question: how can store id number of particular account variable? cannot produce id number , output receive when entering existing account 'id number -->' without following id.

db column names: id, username, password.
$username, $password , $submit post variables.

either change name of column in query:

 $sql = "select id id users username='$username' , password='$password'"; 

or when try fetch it:

$id = $row['id']; 

also please don't store passwords plaintext. read on how handle passwords in php.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -