Results 1 to 3 of 3

Thread: Login Form with PHP. How to proceed?

  1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    12

    Default Login Form with PHP. How to proceed?

    Hi all,

    I know that this sounds very simple, but I have not managed to make it work. Basically I got a simple Ext Js login form. The form submit to my login.php, which performs a database check and if the user exist, then issues a 'success:true' JSON string back to Ext JS.

    Now the question, how do I redirect then the user to my other script 'home.php'? I have tried to put a redirection just after the 'echo '{success:true}' but it does not seem to work. Also I tried to make an ajax request from the Ext Js, but it doesn't work either...I cannot get through the TRUE/FALSE json thing! How can I make it work? I just want to call another script when the login validation is successful.

    Here is a sample of my extjs login request:

    buttons: [{
    text: 'Login',
    handler: function(){
    if(loginForm.getForm().isValid()){
    loginForm.getForm().submit({
    waitMsg: 'Processing Request',
    success: function(f,a){
    msg('Success', a.result.msg);
    }
    });
    }
    }
    }]

    And the login.php has a method called 'submit' that is the one being called by the login form. I post here a very simplified version, as I do a database validation. Also I use sessions to prevent non authenticated users to access any other script:

    public function submit() {
    // set the logged COOKIE to True
    $this->session->set_userdata('logged', TRUE);
    echo '{success:true, msg:'.json_encode("Welcome").'}';
    redirect('home.php');
    }

    I am using CodeIgniter on the php side, but in anycase, if I use 'header()' instead of 'redirect()', it does not work either. I get the ExtJs waiting message stuck in a neverending loop.

    Sorry for not using the code format tags, it's not working from Chrome (I do not why).

  2. #2
    Sencha User
    Join Date
    Jan 2008
    Location
    Maryville, IL, US
    Posts
    288

    Default

    You can't use the PHP page to redirect, but you could pass the URL from it.

    from extjs form
    Code:
    ...
    ,success: function(f,a) {
         document.location = a.result.url ;
    }
    ...

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    12

    Default

    Hi, thanks alot! It's working now

Posting Permissions

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