php - How can i use Salt with a password in codeigniter when retrieving salt from the db -
This is my model, I am querying the database, it needs to be retrieved which I want, then the comparison I am doing Excluding the query is not a column of salt as a column name, but as a string, which is fine, except that it is treating the salt word as a string, there is no data from the database. How can i come
function login ($ username, $ password) {$ this- & gt; Db- & gt; Query ("choose firstname, user name, password, salt with table_name WHERE user name = '$ username' AND password = 'sha1 (salt password' '); $ this-> db-> border ( 1); `$ query = $ this- & gt; db- & gt; mill (); if ($ query-> Num_rows () == 1) {return- $ query-> results (); // data is true} and {return false; // data is wrong}}
There are some things to play here: First of all, you are adding ' to hash. . does not use the operator. Try the following: Try the following: First name, user name, password, salt from table_name WHERE user name = '$ user name' and password = Sha1 (CONCAT (salt, '$ password' )) Please make sure that both the $ username and $ password are otherwise properly preserved you have the SQL injection It is better to use a better prepared statement again in CodeIgniter. Expertise, but information can be found at:
edit: query binding code will work in Ignetr
Comments
Post a Comment