-1
<div class="sidenav">
    <ul>
        <li><a href="mainpage.php">Dashboard</a></li>
        <li><a href="mainpage.php?page=myevent">My Event</a></li>
        <li><a href="mainpage.php?page=upcomming">Upcomming Event</a></li>
        <li><a href="mainpage.php?page=pastevents">Past Event</a></li>
        <li><a href="mainpage.php?page=myprofile" >My Profile</a></li>
    </ul>
</div>
  <div class="body" style="padding-left: 20px;">

  <?php
    $p = $_GET['page'];
    $pages = $p.".php";
    if(file_exists($pages))
    {
        echo "Found the page";
    } 
    elseif ($p=="") {
        echo "this is dashboard";
    }
    else
    {
        echo "Page not found";
    }
 ?>

It shows the error for Dashboard.

Notice: Undefined index: page in /opt/lampp/htdocs/eventmanagement/php/mainpage.php on line 134

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98

1 Answers1

0

You need to check page query string is set or not then check further conditions: so change your $p = $_GET['page']; to :

$p = isset($_GET['page'])?$_GET['page']:"";
B. Desai
  • 16,414
  • 5
  • 26
  • 47