Page 1 of 1

JQuery/AJAX Problem

Posted: Sun Nov 21, 2010 9:26 am
by Designer
Hi

I'm having a problem due to my very limited knowledge of JQuery.

I have a very basic log-in form which comprises of two fields email address and password.

On submit I want the following processes to take place:-

Client side validation - done (& working)
If (client side valid) {
Server-side validation using PHP - Check database for valid email address and if found does password match
if (email and password valid) {
transfer control to new URL
}
}

Obviously if not valid at any point stay on current page and display error message.

I have highlighted the JQuery code in red which I believe is where the changes need to be made. We can call the PHP file form.php (where server-side validation takes place etc.)

I'm OK with the PHP coding (calling database etc)


Seems simple at face value but....proving problematic!

Any help greatly appreciated! :banghead: :?


http://www.siteexpeditor.com/example-index.php



[text]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>jQuery Login Form example</title>

<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />

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

<script type="text/javascript">
$(document).ready(function() {
$("#form").validate();
});
</script>


<style type="text/css">
#form { width: 500px; }
#form label { width: 250px; }
#form label.error, #form input.submit { margin-left: 253px; }
</style>

</head>
<body>

<form method="post" class="cmxform" id="form" action="">
<fieldset>
<legend>Login Form (Enter "foobar" as password)</legend>
<p>
<label for="user">Username</label>
<input id="user" name="user" title="Please enter your username (at least 3 characters)" class="required" minlength="3" />
</p>
<p>
<label for="pass">Password</label>
<input type="password" name="password" id="password" class="required" minlength"5" />
</p>
<p>
<input class="submit" type="submit" value="Login"/>
</p>
</fieldset>
</form>

</body>
</html>
[/text]