php - My code is not working properly when I attempt to login -


This is my first time that I am using mysqulli, maybe I made a mistake. Well, I have successfully inserted all the data from the MySQL database for the registration purpose, including the following password hash. $ Random_salt = hash for password ('sha512', uniqid (openssl_random_sese_bytes (16), true)); $ Pass = hash ('sha512', $ password. $ Random_salt);

Well, when I login with the following code it is showing my custom error message "Email address or password is not correct" < Pre> & lt ;? Php ob_start (); Session_start (); Require_once ("include / config.php"); $ Email = inputvalid ($ _ POST ['email']); $ Password = inputvalid ($ _ POST ['password']); // $ random_salt = hash ('sha512', uniqid (openssl_random_pseudo_bytes (16), true)); // $ random_salt = hash ('sha512', uniqid (mt_rand (1, mt_getrandmax ()), true)); // $ pass = hash ('sha512', $ password. $ Random_salt); $ Salt = mysqli_query ($ mysqli, "Select salt members where email = '$ email'"); $ Res = mysqli_fetch_array ($ salt, MYSQLI_NUM); $ Salt = $ res ['salt']; $ Password2 = hash ('sha512', $ password. $ Salt); $ Check = mysqli_query ($ mysqli, "Select email, email to members where email = '$ email' and password = '$ password2'"); $ Num = mysqli_num_rows ($ check); $ Is disabled = mysqli_query ($ mysqli, "Select Active is the member where email = '$ email'"); $ Res = mysqli_fetch_array ($ is active, MYSQLI_NUM); $ Is active = $ res ['is_active']; $ Msg = array (); $ msg ['error'] = false; If (empty ($ email) & amp; amp; blank ($ password)) {$ msg [] = "Both fields are required"; $ msg ['error'] = true; } Elseif ($ num == 0) {$ msg [] = "Email address or password is not correct"; $ msg ['error'] = true; Echo mysql_error (); } Elseif ($ isActive == 0) {$ msg [] = "Sorry, you have not activated the account."; $ msg ['error'] = true; } If ($ msg ['error'] === false) {// Success success success $ $ $ $ _ $ _ ['email'] = $ email; $ _SESSION ['password'] = $ password2; If (isset ($ _ session ['email']) and release ($ _ session ['password'])) {$ msg [] = '& lt; Br / & gt; & Lt; font color = "b9c025" & gt; Login successfully. & Lt; / Font & gt; & Lt; Br / & gt; & Lt; Br / & gt; '; } And {$ msg [] = "no registration session"; $ Msg [] = "reson is" mysql_error (); } // update database ... $ date = date ("D-M-Y H: M: s"); $ Update = mysqli_query ($ mysqli, "Update Member SET last_visit_dt = '$ date', Pageview = Pageviews + 1 where email = '$ email'"); } $ Other = "off"; Echo json_encode ($ msg); ? & Gt;

($ paragraph))); }

Try doing something like this:

Replace

  $ check = mysqli_query ($ mysqli, "select email, email to members where email = '$ email' and password = '$ password2'"); $ Num = mysqli_num_rows ($ check); Select    

Comments

Popular posts from this blog

c++ - ERROR: cannot open source file x11\xlib.h -

c - What are pthread cancelation points used for? -

c# - Show a huge number of data in DevExpress GridView -