Forum Moderators: coopster
pseudo code:
if
referal url is from otherwebsite.com/promo.htm
then
show promo page
else
sorry, promo page not available
Put this at the top of the page. No spaces separating it from the top.
echo ($HTTP_REFERER == "http://otherwebsite.com/promo.htm"?header('Location:promopage.htm'):"Sorry, no promo page available");
...it's all one line. Substitute a variable with a longer "Sorry" notice, or another header("location:etc... if you like.
T
I'd just mention though that it's fine to put as much PHP as you want before the header statement, provided that no HTML appears prior to it.
When I say no HTML, that includes extraneous spaces before the PHP, so you could put
<?PHP
echo ".....";
$name = "....";
header etc..
?>
but the <?PHP MUST be the very first characters of the very first line.
Unless you enable output buffering header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP (echo '...'; in kcartlidge´s example).
Andreas
So there´s no cause for toadhall´s concern about any variable declaration [coming] before the header() function.
Andreas
You're very right. I just went ahead and typed in some 'random' PHP above the header. Unfortunately, the most common statement I use is 'echo' and I typed it without even thinking [doh].
In one breath I say NO OUTPUT, in the next I use an ECHO command - pretty stupid huh?
Yes, NO OUTPUT before header and all's fine.
No, don't use the ECHO statement before the header.
Many thanks for pointing it out ...