I`m getting these errors:

Notice: Undefined index: like in C:\Program Files\wamp\www\fb\header.php on line 5
Notice: Undefined variable: page in C:\Program Files\wamp\www\fb\header.php on line 12
Notice: Undefined variable: page in C:\Program Files\wamp\www\fb\header.php on line 15
Notice: Undefined variable: page in C:\Program Files\wamp\www\fb\header.php on line 18
Notice: Undefined variable: page in C:\Program Files\wamp\www\fb\header.php on line 21

This is my header.php :

<? include('config/config.php');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<? if($_GET['like']){ 
    $new_title = stripslashes($rock);
    $seo_title = '&#1061;&#1072;&#1088;&#1077;&#1089;&#1074;&#1072;-&#1084;&#1080; - '.$new_title;
    $ntitle = substr($seo_title,0,47);
    ?>
<title><? echo stripslashes($ntitle).'...'; ?></title> 
<? }else{ ?>
<? if($page == 'top20'){ ?>
<title>&#1061;&#1072;&#1088;&#1077;&#1089;&#1074;&#1072;-&#1084;&#1080; - &#1058;&#1086;&#1087; 20</title> 
<? } ?>
<? if($page == 'random'){ ?>
<title>&#1061;&#1072;&#1088;&#1077;&#1089;&#1074;&#1072;-&#1084;&#1080; - &#1057;&#1083;&#1091;&#1095;&#1072;&#1081;&#1085;&#1080;</title> 
<? } ?>
<? if($page == 'pics'){ ?>
<title>&#1061;&#1072;&#1088;&#1077;&#1089;&#1074;&#1072;-&#1084;&#1080; - &#1050;&#1072;&#1088;&#1090;&#1080;&#1085;&#1082;&#1080;</title> 
<? } ?>
<? if($page == ''){ ?>
<title>&#1061;&#1072;&#1088;&#1077;&#1089;&#1074;&#1072;-&#1084;&#1080; - &#1057;&#1098;&#1079;&#1076;&#1072;&#1081;&#1090;&#1077; &#1089;&#1074;&#1086;&#1080; &#1092;&#1088;&#1072;&#1079;&#1080;</title>
<? } ?>
<? } ?>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

What i have to change in this code, pls help 😕

    Even though PHP is a lazy-typed language you might want (especially in later versions of it) to define your variables before just popping them up from nowhere. The first undefined ($_GET['like']) you are getting can be solved by using the isset() method which checks if the index actually is set. The later undefined variable ($page) should be set somewhere/initiated before it's used in the checks.

      I fix the first error with like(undefined index) with

      <? if(isset($_GET['like'])){ 

      , but still can`t fix the errors with Undefined variable: $page . How it can be done pls give me examples. thanks in advance 😕

        So, $page is supposed to be an incoming variable such as $GET['page']? If so, use $GET['page'], checking with [man]isset[/man] or [man]empty[/man] as appropriate.

          Thanks to all, the problem is solved ! There is solution for Undefined variable $page :

          <? if(empty($_GET['page']) == 'top20'){ ?>
          <title>&#1061;&#1072;&#1088;&#1077;&#1089;&#1074;&#1072;-&#1084;&#1080; - &#1058;&#1086;&#1087; 20</title> 
          <? } ?>
          <? if(empty($_GET['page']) == 'random'){ ?>
          <title>&#1061;&#1072;&#1088;&#1077;&#1089;&#1074;&#1072;-&#1084;&#1080; - &#1057;&#1083;&#1091;&#1095;&#1072;&#1081;&#1085;&#1080;</title> 
          <? } ?>
          <? if(empty($_GET['page']) == 'pics'){ ?>
          <title>&#1061;&#1072;&#1088;&#1077;&#1089;&#1074;&#1072;-&#1084;&#1080; - &#1050;&#1072;&#1088;&#1090;&#1080;&#1085;&#1082;&#1080;</title> 
          <? } ?>
          <? if(empty($_GET['page']) == ''){ ?>
          <title>&#1061;&#1072;&#1088;&#1077;&#1089;&#1074;&#1072;-&#1084;&#1080; - &#1057;&#1098;&#1079;&#1076;&#1072;&#1081;&#1090;&#1077; &#1089;&#1074;&#1086;&#1080; &#1092;&#1088;&#1072;&#1079;&#1080;</title>
          <? } ?>

            By the way, avoid short open tags, i.e., use <?php instead of <? as short open tags are not guaranteed to be enabled.

              Also, your if() statements are still incorrect. This:

              if(empty($_GET['page']) == 'top20'){

              is comparing the boolean response from [man]empty/man to a string. In other words, you're doing:

              if(true == 'top20'){

              which obviously doesn't make sense (nor is it what you wanted).

              Instead, check if [man]empty/man is false and then compare the string to the actual variable itself.

                Write a Reply...