I know this site isn’t asking for people to work on a specific code, but I’m having a real hard time looking for examples/tutorial on jquery mobile login. I’m not sure if I’m doing this right, but I’m trying to get a user to login based on mysql database (if user is in my database), but I’m trying to figure out what to write up when user logs in? How do i set up so it will redirect to home page?
PHP page
if(isset($_POST['email']) && isset($_POST['pass'])){
$email = mysql_real_escape_string($_POST['email']);
$password = md5(mysql_real_escape_string($_POST['email']));
$sql = mysql_query("SELECT password,email FROM users WHERE email = ".$email." AND password = ".$password." LIMIT 1");
}
index.html
$('form#login').submit(function(){
var email = $("form#login input.email").val();
var pass = $("form#login input.pass").val();
$.post("ajax/post_login.php", {email: email, pass: pass},
function(data){
alert("failed"); //if not logged in
});
});
I’m having trouble here?
Can someone help me out with jquery mobile?
I have different many <div data-role="page">(content here)</div> and I want to know how to access a certain page, when logged in? and if email/username fails, theres an error?
I appreciate your help! Thank you!
I solved it by posting the login data to the server with custom AJAX and letting the server respond with a JSON object containing the data needed to take an appropriate action.
The script looked something like this (uses jQuery):
And sample JSON data returned from server side: