-3

The following code has been moved to a new server and is throwing this error:

Notice: Undefined variable: menu in * on line 128
Notice: Undefined variable: menu in * on line 160
Notice: Undefined variable: menu in * on line 170

Here is the code:

<a href="index.php?menu=profile">Profile</a>
<a href="index.php?menu=regisztracio">Regisztráció</a>
<a href="index.php?menu=kapcsolat">Kapcsolat</a>
<?php switch($menu)
{
    case "profile":
    {
        echo("profil");
    }
    case "regisztracio":
    {
        echo("regisztráció");
    }
    case "kapcsolat":
    {
        echo("kapcsolat");
    }
    default:
    {
        echo("Home page");
    }
}
?>
salathe
  • 51,324
  • 12
  • 104
  • 132

3 Answers3

1

I didn't understand your lang but the problrem is you are not using $_GET['menu'] to retrieve the GET parameter.

$menu = $_GET['menu'];
switch($menu) {
....
}
Yogesh Suthar
  • 30,424
  • 18
  • 72
  • 100
1
<a href="index.php?menu=profile">Profile</a>

<a href="index.php?menu=regisztracio">Regisztráció</a>

<a href="index.php?menu=kapcsolat">Kapcsolat</a>

here "menu " is not a php variable. You should pass value as $menu to switch ( $menu = $_GET['menu']; ). Not "menu" to switch.

Balaji Kandasamy
  • 4,446
  • 10
  • 40
  • 58
0

$menu is undefined.

It is not set anywhere, e.g.

$menu  = "profile";
Jake N
  • 10,535
  • 11
  • 66
  • 112