Jump to content

[SOLVED] Help with If statement.


divadiva

Recommended Posts

I am trying to run an  IF statement here. If my weblink is  ($fdl=@fopen($fileString ,'r')&& $_GET["entryPoint"]== removeme && $_GET["entryPoint"]== campaign_tracker2 && $_GET["entryPoint"]== campaign_tracker)I should get access to the file.If the $_GET in the link  is not equal to removeme,campaigntracker or campaigntracker,I should get "Cannot open open.

ANy help will be apprciated;

 

This is the link

 

http://www.xyz.com/index.php?entryPoint=campaign_trackerv2&track=a67fd05b-0804-e4bb-456e-496f69e036bc

 

if($fdl=@fopen($fileString ,'r')&& $_GET["entryPoint"]== removeme && $_GET["entryPoint"]== campaign_tracker2 && $_GET["entryPoint"]== campaign_tracker){  //Check for File existence
       
  	$contentType = 'text/html';

header("Cache-Control: ");// leave blank to avoid IE errors
  	header("Pragma: "); // leave blank to avoid IE errors

header("Content-type: $contentType");
  	
    	fpassthru($fdl);

}
else  {
       die("Cannot Open File!");
}



Link to comment
https://forums.phpfreaks.com/topic/140971-solved-help-with-if-statement/
Share on other sites

first, you need single quotes around those values...and it should be || or OR. but in_array is easier:

 

if($fdl=@fopen($fileString ,'r') && in_array($_GET["entryPoint"], array('removeme','campaign_tracker2','campaign_tracker')){  //Check for File existence
       
     $contentType = 'text/html';
   
   header("Cache-Control: ");// leave blank to avoid IE errors
     header("Pragma: "); // leave blank to avoid IE errors
   
   header("Content-type: $contentType");
        
       fpassthru($fdl);
   
   }
   else  {
       die("Cannot Open File!");
   }
    


Thankyou once again.It works but I am unable to open web page which I was able to  before.But now I cannot access that page for some reason.Could it be because of the $_GET I am using.

I mean the if statement .Please see my code.

 

This is the webpage :

http://www.xyz.com/index.php?entryPoint=campaign_trackerv2&track=a67fd05b-0804-e4bb-456e-496f69e036bc .

 

 

$fileName = "index.php"; //Provide a valid file name.

$fileLink ='?entryPoint='.$_GET["entryPoint"].'&identifier='.$_GET["identifier"];//Add the additional links

$fileString = $fileDir.'/'.$fileName.$fileLink;//Append all the links 

  
if(!$fdl=@fopen($fileString ,'r') && in_array($_GET["entryPoint"], array('removeme','campaign_tracker2','campaign_tracker'))){//Looking for a reason why webpage cannot be opened .Before I was able to open the page.

       die("You dont have rights to open the file!");
}
	else 
{
	$contentType = 'text/html';

header("Cache-Control: ");// leave blank to avoid IE errors
  	header("Pragma: "); // leave blank to avoid IE errors
header("Content-type: $contentType");
  	
    	fpassthru($fdl);

}
?>


 

 

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.