Jump to content

If/else statement not working in included file


jhodara

Recommended Posts

Hi,

My issue here is that I cant get my if/else statement to work on my secondary page. I include my secondary page (fine.php) from my index page. However, I have an if/else statement in fine.php that keeps reverting back to the index.php and, therefore, outputs the else statement (404.php)

 

here is the if/else on index.php (these links work fine):

 

<?php
if($_SERVER['QUERY_STRING']=='/index.php' || $_SERVER['QUERY_STRING']=='')
{
		include 'port.php';
}		

elseif (isset($_GET['pos'])){
		include 'pos.php';
}	

elseif (isset($_GET['web'])){
		include 'web.php';
}

elseif (isset($_GET['fine'])){
		include 'fine.php';
}	

        else {include '404.php';}


 

 

 

here is the if/else on my secondary page (fine.php). These links are supposed to alert the if/else in the next table cell. However, they instead alert the if/else in index.php.

 

	
<td><br/>
<a href="?backset"><img src="fine/thumbs/x-backset.jpg" border="0"></a><br/><br/> 
<a href="?backside"><img src="fine/thumbs/x-backside.jpg" border="0"></a><br/><br/> 
<a href="?bannerprint"><img src="fine/thumbs/x-bannerprint.jpg" border="0"></a><br/><br/> 
<a href="?chopu"><img src="fine/thumbs/x-chopu.jpg" border="0"></a><br/><br/> 
</td>
<td><br/>
<div id="DivPiece" align="left">
<?PHP 

if (isset($_GET['backset'])){
       include 'fine/backset.php';
}

elseif (isset($_GET['backside'])){
     include 'fine/backside.php';
}	

elseif (isset($_GET['bannerprint'])){
     include 'fine/bannerprint.php';
}

elseif (isset($_GET['chopu'])){
include 'fine/chopu.php';
}

?>
</div>
</td>

 

How can I get the links on the secondary page to only alert the if/else statement on that page, and BLOCK the if/else statement on index.php from seeing them? I still want to use the query string though.

 

Thanks!

So basically I need the php to skip over the first if/else statement and look straight in the next one. Anyone know how to do this?

 

Is there an else {look in this file} type code that I can use at the end of my first if/else so It doesnt spit out the 404?

 

 

 

Hi,

My issue here is that I cant get my if/else statement to work on my secondary page. I include my secondary page (fine.php) from my index page. However, I have an if/else statement in fine.php that keeps reverting back to the index.php and, therefore, outputs the else statement (404.php)

 

here is the if/else on index.php (these links work fine):

 

<?php
if($_SERVER['QUERY_STRING']=='/index.php' || $_SERVER['QUERY_STRING']=='')
{
		include 'port.php';
}		

elseif (isset($_GET['pos'])){
		include 'pos.php';
}	

elseif (isset($_GET['web'])){
		include 'web.php';
}

elseif (isset($_GET['fine'])){
		include 'fine.php';
}	

        else {include '404.php';}


 

 

 

here is the if/else on my secondary page (fine.php). These links are supposed to alert the if/else in the next table cell. However, they instead alert the if/else in index.php.

 

	
<td><br/>
<a href="?backset"><img src="fine/thumbs/x-backset.jpg" border="0"></a><br/><br/> 
<a href="?backside"><img src="fine/thumbs/x-backside.jpg" border="0"></a><br/><br/> 
<a href="?bannerprint"><img src="fine/thumbs/x-bannerprint.jpg" border="0"></a><br/><br/> 
<a href="?chopu"><img src="fine/thumbs/x-chopu.jpg" border="0"></a><br/><br/> 
</td>
<td><br/>
<div id="DivPiece" align="left">
<?PHP 

if (isset($_GET['backset'])){
       include 'fine/backset.php';
}

elseif (isset($_GET['backside'])){
     include 'fine/backside.php';
}	

elseif (isset($_GET['bannerprint'])){
     include 'fine/bannerprint.php';
}

elseif (isset($_GET['chopu'])){
include 'fine/chopu.php';
}

?>
</div>
</td>

 

How can I get the links on the secondary page to only alert the if/else statement on that page, and BLOCK the if/else statement on index.php from seeing them? I still want to use the query string though.

 

Thanks!

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.