You'll get that notice when no element named 'action' exists in the $GET array, which will occur if the page is accessed without a "?action=some_value" in the URL. While you could avoid the notice by suppressing errors, the better solution is to add a test to see if it exists.
// assign value if it exists, else blank
$action = (isset($_GET['action'])) ? $_GET['action'] : '';
// now do your switch with the new variable:
switch($action) {
case 'add':
print "Show the add testimonial form here";
break;
default:
print "Show all the testimonials we have here.";
}
PS:
first, thanks for reply. I know the code is right no problem in code, as I was following one video training, same thing is working in video but not in my machine.
The video probably was running on a server where the PHP configuration had the display_errors setting turned off or at an error_reporting level that did not display notice-level warnings, allowing the tutorial author to get away with sloppy code.