jquery form submission

Okay i am not able to get any valuable results when i submit a form through jquery post() method. I am able to get login.php and username and passwod entered as a RESPONSE when i click the submit button . but i am not sure what data field is upto !! is it empty ?? or what , no idea whatsover !!
please help .

Here is the link to custom.js
http://pastebin.com/CNGGswcD
And for validation file login.php link is
http://pastebin.com/zjLLNcXd

The data argument is a response from your login.php script as json object. For example, if you put this in your login.php script:
[php]echo ‘{“response”:“Success”,“status”:“Logged in”}’;[/php]

then you can do this in your javascript:

$.post("login.php", {username:user.val(), password:pass.val()}, function(data){ if(data){ alert(data.status); } });

authenticate login using jquery
For this you have to create two file first file will be simple html file having login form(login.html) and second file is a php file having login authentication logic(logincheck.php)

First file login.html
[php]
// save code as login.html

LOGIN FORM By Sanjay

Login Form

Username:

Password:

[/php]

second file logincheck.php

[php]
// save code as logincheck.php

$is_ajax = $_REQUEST[‘is_ajax’];
if(isset($is_ajax) && $is_ajax)
{
// you can put here your logic for checking user name and password which is stored in
// your database
// here i have set static values for testing

            $username = $_REQUEST['username'];
	$password = $_REQUEST['password'];

	if($username == 'sanjay' && $password == 'sanjay')
	{
		echo "success";
	}
}

[/php]

by default i have set valid user detail as
user name : sanjay
password : sanjay

I hope this will helpful for you

Thanx

Books in PDF format, free to download
http://goo.gl/sQzrU

Sponsor our Newsletter | Privacy Policy | Terms of Service