Redirection if a condition is met



I know this topic has been discussed a few times here and also on
php.net, but I cannot find an answer to my specific problem. I check to
see if a user is logged in before serving admin.php like so:
<?php
session_start();
if (!isset($_SERVER['username']) or !isset($_SERVER['password'])) {
header("location:http://linux-place.com";);
exit;
}
?>
These are the very first lines in the file. It works perfectly. The
problem is that I would like to output a message like "Please login
first before accessing the administration panel". How can I do that
without getting the headers already sent error?

Thanks,
Ahmed El-Daly

.



Relevant Pages

  • Re: Redirection if a condition is met
    ... > problem is that I would like to output a message like "Please login ... > first before accessing the administration panel". ... check if headers are sent, if not use header to redirect ... if headers are sent already, print a javascript relocation routine ...
    (comp.lang.php)
  • Re: OE identity switching problem(s)
    ... > the right incoming messages into that wrong inbox. ... Is Exit and Log off Identity supposed to do a File Exit too? ... Another user then tries to login to a different identity before any reboot. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Failsafe mode
    ... > and paste or failing that copy the message down character for ... >> If I exit out and log back in as my alternate user ... user command line prompt in the upper left corner and a black blank screen. ... If I ctl alt F1 I get the system login prompt. ...
    (alt.os.linux.suse)
  • Re: Back and Forward Page
    ... When I do exit, I'll go to the login page again, right? ... Hope this help you ruca "Cowboy " escreveu na ... >> Do you know how can I disable the Back and Forward commands in browser? ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Back and Forward Page
    ... When I do exit, I'll go to the login page again, right? ... Hope this help you ruca "Cowboy " escreveu na ... >> Do you know how can I disable the Back and Forward commands in browser? ...
    (microsoft.public.dotnet.framework.aspnet)