Results 1 to 3 of 3

Thread: Redirect after login doesn't work

Threaded View

  1. #1
    Join Date
    Jan 2013

    Unhappy Redirect after login doesn't work

    for what reason this code doesn't work?

    PHP Code:


    or die(
    "Unable to connect to MySQL");

    //select a database to work with
    $selected mysql_select_db("my_americanhorizon",$con)
      or die(
    "Could not select my_americanhorizon");

    $sql="SELECT * FROM negozi WHERE Username='$f_usr'";


    $datiUtente==array()) // if empty array
    header("Location: userPanel.php"); //successfully logged


    in the php page that contains the form, the "Sorry" response is correctly processed, while header("Location: userPanel.php"); for redirect the page to the userpanel if successfully logged doesn't work

    This is the form page (it's not necessary that you read it, it's should be correct. Only one doubt, i wrote the condition "if (ajaxReq.responseText == "Sorry")"... Maybe i've to write a condition in case of redirection too?)

    HTML Code:
     <div id="logindAndRegistra">
         <div id="sezionesx">
           <div class="scritta" id="loginHeader">Login</div><br />
           <div class="scritta">eMail <br /><input id="username"/></div><br />
           <div class="scritta">Password <br /><input id="password"/></div><br />
           <button id="loginVai">Vai -></button>
    $('#loginVai').click( function() 
    						 var ajaxReq = new XMLHttpRequest();
    						 var params = "username="+$('#username').val()+"&password="+$('#password').val();
    						 var url = "tentaLogin.php";
    						 ajaxReq.open("POST", url, true);
    						 ajaxReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    						 ajaxReq.setRequestHeader("Content-length", params.length);
    						 ajaxReq.setRequestHeader("Connection", "close");
    						 ajaxReq.onreadystatechange = function() 
    														  if(ajaxReq.readyState == 4 && ajaxReq.status == 200) 
    															  if (ajaxReq.responseText == "Sorry")
    																  $('#sezionesx').append($('<div id="loginSbagliato" class="baloon up scritta">I dati inseriti sono errati</div>'))
    Last edited by American horizo; 04-14-2013 at 09:30 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center