javascript - ajax login form doesn't work -
I am trying to pass the user's information to mysql on the webpage, if the user is logged in but get it Have not worked. If I enter an incorrect email or password then this error message will show but if the credentials are ok then it will do anything ...
on the php file:
$ sql = "Select * from user where email = '$ l_email' and password = '$ l_password'"; $ Query = mysql_query ($ sql) or die ('Error:'. Mysql_error ()); $ Num_rows = mysql_num_rows ($ query); If ($ num_rows & lt; 1) {echo "you have entered an incorrect email or password!"; } And {$ memberInfo = array (); While ($ line = mysql_fetch_array ($ query)) {$ memberInfo [] = $ line; } $ Member returned INFO; Echo json_encode ($ memberInfo); // resonance "1"; } on the JS file:
$ .post (includes ". / Include / checkOut.php"), {l_email1: l_email, l_password1: l_password }, Function (data) {if (data == '1') $ ("# checkOut_form") [0]. Reset (); $ ("# login_returnmessage") .HTML (""); $ ("# memberInfo ") (For member member information) {var f_name = memberInfo [i] .f_name; var l_name = memberInfo [i] .l_name; var phone = member infighted (" "); var member (internet) = jQuery.parseJSON $ ('#_f_name') Val (f_name); $ ('#_l_name') Val (l_name); $ ('# _email') Val (l_email); $ ('#_phone') Val (Phone);} $ ("# login_full message") .html (data);});
If you use return outside a function So it ends, the script at that point is what you are doing here:
return $ memberInfo; Echo json_encode ($ memberInfo); // resonance "1"; You have to remove the return statement.
You should also add Content-type: header to respond to the browser to expect JSON:
header -Type: Application / Jason '); Echo json_encode ($ memberInfo); Your JavaScript code is checking the response to the value 1 , which you are not sending, so the update code will not execute the code. / P>
Finally:
- Do not store passwords in unencrypted -
password_hash () - Do not use
Mysql has been disliked as- UsemysqliorPDOto make sure it's your database (Or better, prepared statement (mysql _ * () is not supported by.
Comments
Post a Comment