php - why is the password is not matching after md5 encryption? -


md5 encryption set in database,then in login.php use select statement match:

<?php     session_start();     include"db.php";     if ( isset( $_post['email_id'] ) ) {         $email_id = $_post['email_id'];         $password = $_post['password'];         $sql="select * user email_id='$email_id' , password='md5($password)' limit 1";         $res = mysql_query($sql);         $count = mysql_num_rows($res);         if ( $count == "1" ) {             $row = mysql_fetch_array($res);             $name = $row["first_name"];             $_session["name"] = $name;             $_session["password"] = $password;             header("location:index.php");             exit();         } else {             echo "invalid login information.";             exit();         }     } ?> 

the message 'invalid login information' displayed.

you need concat string

$sql = "select * user          email_id='$email_id'          , password='".md5($password)."' limit 1"; 

or better this

$password = md5($fetched_password); $sql = "select * user          email_id = '$email_id'          , password='$password' limit 1"; 

and don't have use limit 1 query has fetch unique row else db design not correct, instead e-mail, use unique user id's


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -