Juliette Juliette - 4 months ago 9
PHP Question

PHP site changes with Get parameters

so I have this really weird bug and I have no idea why it occurs:
I have an "index.php" with header and footer and in the middle it includes a "Content.php", that outputs the content, depending on which Get-parameter the index.php has:

if($_GET["site"]){
switch($_GET["site"]){
case 1:
break;
case 2:
if($_GET['horses']){
include_once("horses.php?horse=".$_GET['horses']);
} else{
include_once("horses.php");
}
break;
case 3: include_once("contact.php");
break;
case 4:
if($_GET['members']){
include_once("team.php?member=".$_GET['members']);
} else{
include_once("team.php");
}
break;
case 8: include_once("pressestimmen.php");
break;
default: include_once("home.php");
}
} else{
include_once("home.php");
}


In some cases (horses and Team members) a second Get-Parameter is passed that is processed inside the corresponding Content-file.

This works perfectly well for the horses and behaves as expected but for some reason, even though I copied the code (except some details) in the "team.php" NO content at all is shown, when I pass a Get-parameter. This in itself wouldn't be too suprising, as I might have a bug in the php somewhere but even when I change team.php to:

<div class="margin-bottom-30">
</div>
<div class="tabs">
<ul class="nav nav-tabs">

</ul>
</div>
<div class='tab-content'>

</div>



When I call "index.php?site=4" it works without problems and shows the empty containers. But when I call "index.php?site=4&members=1" the Content is completetly empty and I don't understand how this is even possible considering html shouldn't even notice the get parameter.

I've tried to fix this for hours and I just can't figure out how the Get-parameter could possibly affect the html code inside team.php

Answer

Try changing your case 4 block like this;

case 4:
    include_once("team.php");
    break;

Then in your team.php script, try to get the members parameter from $_GET.

Basically, what you are doing in your implementation, is telling php to look for a file called team.php?member=1 instead of looking for team.php and passing the member = 1 parameter.

Since the file team.php?member=1 (or team.php?member=2, ...) doesn't exists on disk, no content is shown.

If you want detailed information on the errors, warnings, ... on your page (e.g. why a page won't load or what php can't find); add these three lines at the top of your page;

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Have a look here for more information; How do I get PHP Errors to display?

Comments