Re: Redirection if a condition is met





aeldaly@xxxxxxxxx wrote:
> 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

i generally use a 3 step procedure:

1. check if headers are sent, if not use header to redirect

2. if headers are sent already, print a javascript relocation routine

3. as a fallback if javascript is disabled, print a normal link

micha

.



Relevant Pages

  • 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". ... without getting the headers already sent error? ...
    (comp.lang.php)
  • Re: Session or browser problem??
    ... The login request is submitting a form. ... Control, Expires, and Pragma headers as below. ... define any additional cache headers. ... redirected back to referring page.At this point,the referrin page ...
    (comp.lang.php)
  • Re: using Perl to auto-login to capitalone.com
    ... >>I am attempting to write a Perl script that can login to my account at ... > more cookies. ... > Because you are looking to wrangle the HTTP request/response headers, ... > browser, Live HTTP Headers, that allows you to view and ...
    (perl.beginners)
  • Net::SMTP::TLS results "EHLO command failed: 220 We do not authorize the use of this system to trans
    ... #Keep debug off in order for web and email to both work correctly on large ... We will use this to login to ... #This part creates the SMTP headers you see ... # line break to separate headers from message body ...
    (perl.beginners)
  • Re: using Perl to auto-login to capitalone.com
    ... > I am attempting to write a Perl script that can login to my account at ... more cookies. ... Because you are looking to wrangle the HTTP request/response headers, ... browser, Live HTTP Headers, that allows you to view and ...
    (perl.beginners)