Question

if(isset($_SESSION['evt_year']) 
   || isset($_SESSION['evt_title']) 
   || isset($_SESSION['evt_sdate']) 
   || isset($_SESSION['evt_place']) 
   || isset($_SESSION['evt_stime']) 
   || isset($_SESSION['evt_etime']) 
   || isset($_SESSION['evt_desc'])) {
    $output.=$_GET['title']; //the error is here
}
else {
    $output.="";
}

Notice the error I got:

Undefined index: title in C:\xampp\htdocs\ICT\abc\cal1\EventCalender\classes\EventRecordForm.php on line 13

Was it helpful?

Solution

You are testing a lot of variables, but none of them are the variable that is read from.

should be e.g.:

if (isset($_GET['title'])) {
     $output.=$_GET['title']; // there is no error here
}

OTHER TIPS

Just check isset() on the $_GET variable before appending it:

if ( isset( $_GET['title'] ) ) $output.=$_GET['title'];

The error occurs because $_GET['title'] has not been populated.

Before you check/use a variable, it needs to be defined or checked it it really exists. This has been introduced in PHP 5.3.0.

WRONG:

$output = $_GET['title'];

CORRECT:

if (isset($_GET['title'])) {
    $output = $_GET['title'];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top