Jump to content

if page equals


ceddy

Recommended Posts

Im a bit of a newbie to php, ive already got something working except i would like to be able to say if page = mypage.php (followed by anything) then print this

 

eg:

 

mypage.php?

mypage.php?&this_could_be_anything

 

what I am using now is:

 

<?php $myIndexPage = "index.php";
$myDomainName = "mydomain.com";
$_SERVER[HTTP_HOST] = strtolower($_SERVER[HTTP_HOST]);
if($_SERVER[REQUEST_URI]=="/".$myIndexPage or $_SERVER[REQUEST_URI]=="/".$myIndexPage."/" or $_SERVER[REQUEST_URI]=="/" or $_SERVER[REQUEST_URI]=="/?currency=EUR" or $_SERVER[REQUEST_URI]=="/?currency=GBP" or $_SERVER[REQUEST_URI]=="/?currency=USD"){
?>

 

you can see ive had to add the currency querystrings to the address... id like to be able to tell it if it begins with index.php as well as index.php with a querystring following it to print something different...

 

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/49126-if-page-equals/
Share on other sites

doesnt that just figure out the current web url?

 

What I want is to be able to say on the index page print a different header then the rest of my site -- which is working with my above code... except for sessions because they are random and different for each user

 

so like if page = index.php*... print this

else print that

 

i just dont know what to use for that *... to tell it whatever follows specified page

Link to comment
https://forums.phpfreaks.com/topic/49126-if-page-equals/#findComment-240721
Share on other sites

not sure i follow the $_GET['? ? ?'] line (without spaces) you said..

 

that is only an example? Id have to fill the ?'s with variables? or will that grab the variables?

 

Cause I could immagine that could work if i could say something along the lines of

 

$get_variable = $GET['???'] == '????';

 

then

 

if ($_SERVER[REQUEST_URI]=="/index.php" . $get_variable) {
echo 'Something';
}

 

however i cant get that statement to work at all

Link to comment
https://forums.phpfreaks.com/topic/49126-if-page-equals/#findComment-240743
Share on other sites

well i thought this would work... but its not for some reason...

 

if(($_SERVER['REQUEST_URI']=="/") && (isset($_GET['currency']))){
echo 'Test';
}

 

which seems it would work from this url

 

http://www.mydomain.com/?currency=USD

 

because the below code does work...

 

$get_variable = 'no querystring';

if ( isset( $_GET['name'] ) ) {
$get_variable = 'with name querystring';
echo $get_variable;

} elseif ( isset( $_GET['currency'] ) ) {
$get_variable = 'with currency querystring';
echo $get_variable;
} else {

echo $get_variable;
}

 

i even tried assigning a value if the querystring existed and doing this... with no joy

 

if(($_SERVER['REQUEST_URI']=="/") && ($get_variable==1)){
echo 'Test';
}

 

any ideas why this isnt working??

Link to comment
https://forums.phpfreaks.com/topic/49126-if-page-equals/#findComment-240790
Share on other sites

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.