![]() |
display login status without refreshing the page Ajax PHP MYSQL
I have following details of my code, in which i am trying to display login results in <div class="errors">
for example : if user name and passwor exist it will redirect to members.php page, if not then it will display msg "incorrect credential". in this code the problem is msg "incorrect credential get displayed even though the username and password is correct. database : login table : register1 3 fields(username,password,email) ********************************************************** Login.php Code:
<head>Loginpost.php Code:
<?php conndb1.php Code:
<?php please give me some suggestion Regards Prash |
I can't get this to malfunction. Your php echos zero if your query works. Almost fool proof. But may I suggest some changes:
You are not encoding the $password, you should. your query asks for everything done by the use of * and you don't need everything, you just need email! so make this change: Code:
$sql=mysql_query("select email from register1 where username='$username' AND password='$password'");Use: Code:
if(mysql_num_rows($sql) == 1)Code:
$info=mysql_fetch_assoc($sql);Now the echo "0"; This is just MHO but I like something more substantial like echo "correct"; and use an else statement to echo "incorrect credential"; for your html ajax return Id change things to: Code:
if(result == "correct")PHP Code:
|
Hi sunfighter
I did the changes but it still slip to incorrect credentials |
Use this line instead to see query errors:
Code:
$sql=mysql_query("select email from register1 where username='$username' AND password='$password'") or die(mysql_error()); |
I have done the following changes
Login.php Code:
<head>Loginpost.php Code:
|
Now that you have added md5 encoding make sure your DB reflects this.
I see you are trying to go to another page with $(document.location = "members.php"); I didn't enclose that, but I did fix the jq ajax: Use this Code:
<script type="text/javascript"> |
Nope it still dosent work.
I have look for some different option. Thanks for the help Sunfighter |
| All times are GMT +1. The time now is 09:15 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.