Jquery php login

I was wondering if somebody can give me a login code example using jquery and php.  I have provided the login process the username is admin and the password is 123

the login process url is.  

http://www.m35117.com/school/login_repsone.php

it returns a yes or no

If the user enters a invalid password a Div will pop up and say invalid password.  If the password is correct it will redirect to another page
stargateatlantisAsked:
Who is Participating?
 
ali_pakkanConnect With a Mentor Commented:
Hope that helps:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="lib/jquery.js"></script>
<script type="text/javascript" src="lib/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.form.js"></script>
<script type="text/javascript">
 
function processLogin(data) {
	if (data == "yes") {
		document.location.href = "login_success.php";
	} else {
		$("#loginresult").html("invalid username or password");
	}
}
 
$().ready(function() {
	$("#loginform").validate({
		rules: {
			username: "required",
			passwd: "required"
		},
		messages: {
			username: "Username cannot be empty",
			passwd: "Password cannot be empty"
		},
		submitHandler: function(form) {
			var options = {
				url: "login_repsone.php",
				success: processLogin
			};
			$(form).ajaxSubmit(options);
		}
	});
});
</script>
</head>
<body>
<form class="loginform" id="loginform" method="get" action="">
	<fieldset>
		<legend>Please provide username and password</legend>
		<p>
			<label for="username">Username (required)</label>
			<input type="text" id="username" name="username" />
		</p>
		<p>
			<label for="passwd">Password (required)</label>
			<input type="text" id="passwd" name="passwd" />
		</p>
		<p>
			<input class="submit" type="submit" value="Submit"/>
		</p>
		<p>
			<div id="loginresult"></div>
		</p>
	</fieldset>
</form>
</body>
</html>

Open in new window

0
 
stargateatlantisAuthor Commented:
It doesn't work at all.  When i test the form without the jquery it works.  
0
 
ali_pakkanCommented:
Oops.. Doesnt work at all?

You included the library files? Are they where they are meant to be?


<script type="text/javascript" src="lib/jquery.js"></script>
<script type="text/javascript" src="lib/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.form.js"></script>

Open in new window

0
 
stargateatlantisAuthor Commented:
Take a look


http://www.m35117.com/school/lgn.php

all the js files are uploaded as well.  
0
 
ali_pakkanCommented:
i cant see any problem.. Would you please double check that the names of the parameters of the input elements and the ones you read in login_repsone.php are same.. "username", and "passwd".

And you can try to put at the beginning of login_repsone.php to trace:

echo "yes";
exit();

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.