Jump to content

If...do nothing... else... do something


Boerboel649

Recommended Posts

This a super quick and easy question (I hope...)

 

Basically I'm righting a little script that will check the HTTP Referer, and if it equals such and such then to do nothing (ie let the user remain on that page.) If it doesn't equal that then it's gonna redirect them to another page. Basically what I need is how to say "do nothing" in PHP... :P Would it go something like this?

 

if(blahblahblah){

}

 

 

??

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/45780-ifdo-nothing-else-do-something/
Share on other sites

Good idea kenrbnsn, however having trouble getting it to work... here's the code:

 

<?php
$condition = "www.myurl.com/referer.php";
if ($HTTP_REFERER != $condition)
     header("www.myurl.com/redirectpage.php ");

?>

 

It isn't redirecting me at all...

try printing the value of $HTTP_REFERER to make sure it's the value you're looking for:

<?php
$condition = "www.steamfootball.com/authorize.php";
echo "condition: {$condition}<br />\n";
echo "http referer: {$_SERVER['HTTP_REFERER']}<br />\n";
if ($_SERVER['HTTP_REFERER'] != $condition){
     echo "'if' condition passed requirements";
     header("www.steamfootball.com/login.php ");
}	 
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.