Hai,


Now Iam try to learn get data via url using json and login to my php page.Last 4 days i tried but still i have problem.

I have login page. it have username and password.In this page i call my php url.when i call this url it will get username and password and then its finally login to my page..i got json response but its not validate into my php page.

Login:

<!DOCTYPE html>
<html lang="en">
<head>

<title>Welcome to FGLMS</title>
<meta charset="utf-8">

<!-- Mobile metas -->
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">

<!-- Those meta will turn your website into an app on the iPhone -->
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="apple-touch-startup-image" href="images/iphone_startup.png">

<!-- Global stylesheets -->
<link href="css/reset.css" rel="stylesheet" type="text/css">
<link href="css/common.css" rel="stylesheet" type="text/css">
<link href="css/form.css" rel="stylesheet" type="text/css">
<link href="css/mobile.css" rel="stylesheet" type="text/css">
<link href="css/special-pages.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="jquery-1.4.3.min.js"></script>
<script type="text/javascript">
function response()
{
$(function(){
var uid=document.getElementById("login").value;
var pass=document.getElementById("pass").value;
alert(uid);
var url="http://localhost/test-mobile/log.php?username="+uid+"& password="+pass;
alert(url);



alert(pass);
$.ajax({
type: 'POST',
url:"http://localhost/test-mobile/log.php?username="+uid+"& password="+pass,
//dataType: alert(url),
//data: {"username" : $("#login").val(), "password" : $("#pass").val()},
//dataType: 'json'
success: function(data) {
var obj = jQuery.parseJSON(data);
//alert("data.members.message");
alert(data);
alert(obj.members.message);
alert(obj.members.success);

},
error: function(){
alert("err");
}
});

});

}
</script>

</head>
<div id="msg">fgfghgfh </div>
<body class="special-page login-bg">

<section id="login-block">
<div class="block-border">

<form class="form block-content" name="login-form" id="login-form" onSubmit="response();" method="post">

<div class="block-header"><img src="images/logo1.gif" /></div>

<input type="hidden" name="a" id="a" value="send">

<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<legend>Login Form</legend>
<label for="login"><span class="big">Username</span></label>
<input type="text" name="login" id="login" class="full-width" value="">
<p></p>
<label for="pass"><span class="big">Password</span></label>
<input type="password" name="pass" id="pass" class="full-width" value="">
</fieldset>
</div>

<button type="submit" class="float-right" id="Log">Login</button>
<p class="input-height">&nbsp;</p>

<p align="left">
<a id="register" href="register.php"> Register</a> | <a id="register" href="conf_form.php">Confirm Register</a>
</p>


</form></div>
</section>



</body>
</html>


PHP:
<?php


require_once("class/clsdatabase.php"); //Connect to SQL

$username = $_GET['username'];
$password = $_GET['password'];
$status = array();

//Check Username
if($username == '') {
$user = 'Username missing';
//$success = true;
$status = array("success"=>"true", "message"=>$user);
//return $status;
}

//Check Password
if($password == '') {
$pass = 'Password missing';
$success = true;
}


//Create SELECT query
$qry = "select * from user_register where emp_code='$username' AND emp_password='$password' AND active='1';";

$result = mysql_query($qry);
$te = mysql_num_rows($result);

if($te == 0 && $username != '' && $password != '') {
$both = 'Invalid username or password';
$success = true;
}


//If there are input validations, redirect back to the registration form
if($te != 0 && $username != '' && $password != '') {

$row = mysql_fetch_assoc($result);
$name = $row['emp_code'];
//$success = true;
$status = array("success"=>"true", "message"=>$name);
//return $status;

}
$data=$status;

//echo $_GET['callback']. '(' . json_encode($status) . ');';
echo '{"members":'.json_encode($data).'}';
// echo json_encode($data);


?>

Please Help Me..

Regards,
Nandhagopal. J