android - Mobile authentification with php/html/jquery -


hello i'm trying simple authentification application on android, use dreamweaver editor. here code, please can tell why i'm not redirected login.php after success authentification.

index.html

<html><head> <meta charset="utf-8"> <title>guide touristique</title> <link href="jquery.mobile.theme-1.0.min.css" rel="stylesheet" type="text/css"/> <link href="jquery.mobile.structure-1.0.min.css" rel="stylesheet" type="text/css"/> <script src="jquery-1.6.4.min.js" type="text/javascript"></script> <script src="jquery.mobile-1.0.min.js" type="text/javascript"></script>  <script language="javascript">  $(document).ready(function() {   $("#loginform").submit(function() {     $.post('auth.php', $(this).serialize(), function(data) {        $("#errorm").html(data); // semicolon missing in code     }); // round bracket , semicolon missing in code   }); // round bracket missing in code   return false; });  </script>  </head>  <body>    <div data-role="page" id="page2">         <div data-theme="a" data-role="header">          </div>         <div data-role="content" style="padding: 15px">             <div style="text-align:center">             </div>             <form id="loginform" method='post'>                 <div data-role="fieldcontain">                     <fieldset data-role="controlgroup">                         <label for="textinput2" style="text-align:right">                            email:                         </label>                         <input id="textinput2" name="login" value="" type="text"/>                     </fieldset>                 </div>                 <div data-role="fieldcontain">                     <fieldset data-role="controlgroup">                         <label for="textinput3" style="text-align:right">                             password:                            </label>                         <input id="textinput3" name="password" value="" type="password"/>                     </fieldset>                 </div>                      <h3 id="errorm"> <?php if (isset($_get['msg'])){             echo "invalid username or password";      }     ?></h3>                 <input type="submit" name="submit" id="submit" data-inline="true" data-  icon="arrow-l" data-iconpos="left" value="login"/>             </form>      </body> </html> 

auth.php

<?php  //sanitize post values $login = $_post['login']; $password = $_post['password'];           $aqry="select * user utilisateur='".$login."' , pswd='".$_post['password']."'";             $conn=mysql_query($eqry);        if( $conn ){      //check whether query successful or not                      if(mysql_num_rows($conn) == 1) {         //login successful         /* $member = mysql_fetch_assoc($conn);         $_session['member_id'] = $member['id'];         $_session['name'] = $member['utilisateur']; */          header("location: login.php");         exit();         }                               else {               //login failed           header("location: mobile/mlogin.php?msg=invalid%20name%20or%20password");                exit();               }  ?> 

login.php

<!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=utf-8" /> <title>login</title> </head>  <body> you're logging on </body> </html> 

you doing login via ajax request $.post(), means redirect sending being captured ajax request. if in firebug or similar, should see result of ajax call login.php.

i'd recommend having auth.php return json response (see http://php.net/manual/en/function.json-encode.php) {"result":"success", "redirect":"login.php"} or {"result":"error", "message":"abcd"}

in ajax response handler:

if (data.result == "success") {     window.location = data.redirect; } else {     $("#errorm").html(data.message); } 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -