0

I'm having a little problem with a redirection code after a login.

Since i have 2 different ways to login to my website (either from the login page, or from the header of the website) i had to put 2 different redirections path regarding which way of logging in the user used.

So in my header's login form i added this :

<input type="hidden" name="redirect" value="redirect">

And this code where the login datas are processed :

// reload
    if(isset($_POST['redirect'])){
            header('location:http://apatikgg.home');  
        }else{
            header('Location: '.gatorconf::get('base_url').'/?cd=');
            die;
        }
}

That did the trick, but the login takes a full second from when i press my submit button to the moment i get redirected.

Now i know that doesn't sound much "1 second" but it's about 20 times longer than what it took before i added my code, which was pretty much a instant redirection. It only happens when i log from my header's login form (where the "redirect input value" is). Would anyone know why it takes that long to process this few code ?

Or is there a better way to do what i tried to do ?

Any suggestions are welcome

Thank you !

I add that the simple redirection that was present before i add my condition php code was the following :

    // reload
    header('Location: '.gatorconf::get('base_url').'/?cd=');
    die;
}

it doesn't look i added very much

second edit: i'm adding my full header's Login form, maybe this can help.

<form method="post" action="/ftp/index.php?login=1">

        <div id="username">
            <input type="text" name="username" id="txt_username" placeholder="username" required="" value="" />
        <span class="username_icon"><i class="fa fa-user"></i></span>
        </div>
        <div id="password">
        <input type="password" name="password" id="txt_password" placeholder="password" required="" />
        <span class="password_icon"><i class="fa fa-lock"></i></span>
        </div>
        <div id="stay_connected">
        <input type="checkbox" name="chk_connected" id="chk_connected"> 
        <label for="chk_connected"><span>Stay Connected</span></label>
        </div>
        <div id="submit_button">
        <input type="hidden" name="redirect" value="redirect">
        <button type="submit" name="submit" id="sub_login"><i id="submit"class="fa fa-long-arrow-right"></i></button>
        </div>
        <div class="feedback">login successful <br />redirecting...</div>

        </form>
apatik
  • 383
  • 4
  • 17
  • (1) does your redirect header take so long to come through, or is that other side just loading slow? (2) what happens if you `exit()` right _after_ your header redirect? (3) if you want to know what takes a long time, don't guess, profile it with `xdebug`. – Wrikken Oct 15 '15 at 19:23
  • Thanks for your answer, That works ! I actually misread your comment and added die; instead of exit() and it worked, so thanks a lot. If i can ask you, what does exit() do basically ? and what is the difference between exit and die ? Also if you don't mind posting your answer so i can approve your response for this thread. Thanks ! – apatik Oct 15 '15 at 19:31
  • `exit` & `die` are equivalent in all respects. – Wrikken Oct 15 '15 at 19:58

0 Answers0