Jump to content

If/else statement not working in included file


jhodara
 Share

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!

Link to comment
Share on other sites

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?

 

 

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.