Hi all, someone knows or has realized an authentication form calling a
external PHP file for the authentication, in order to remain to the
inside of the main page (index.php)

All I want realize is this, when I click on submit, I call the
login.php file that control user and password. What I must give back in
both of case?

I've posted my solution, it works, but I'm not sure of it, may be
there's a better way, more secure.

Any idea, suggestions, code, corrections are welcome.

My code in index.php

$(document).ready(function(){
  $('#formLogIn').ajaxForm({
        success: showResponse
  });
            
  function showRequest(formData, jqForm, options) {
     var queryString = $.param(formData);
        alert(queryString);
        return true;
  }
            
  function showResponse(responseText, statusText) {
     if(responseText == "Yes") {
        // Show/Hide DIV, I'no not problem to implement that :)
     }
     
     if(responseText == "No") {
        alert("It does not exist");
     }
  }

<form id="formLogIn" method="post" action="login.php">
    Username : <input id="u" type="text" name="username" />
    Password : <input id="p" type="password" name="password" />
    <input id="submit" type="submit" name="submit" value="Entra" />
</form>

login.php contains a simple query to a DB and returns :
        echo "Yes" // if exists
        echo "No" // if not exists

--
Massimiliano Marini - http://www.linuxtime.it/massimilianomarini/
"It's easier to invent the future than to predict it."  -- Alan Kay

Reply via email to