Jump to content

Rather stuck using "include $_GET..."


Bodhran

Recommended Posts

 

I am having some real problems with the code in red below which sits in my "index.php" file, and would be very grateful for any help!

 

<?php

include("header.php");

include $_GET["view"] . ".php";

include("footer.php");

?>

 

The links for my "views" (e.g. <a href="?view=page_news">News</a> ) are in my "header.php" file.

 

The whole website works absolutely fine, except when you first arrive on the homepage you get:

Notice: Undefined index: view

Warning: include(.php) [function.include]: failed to open stream: No such file or directory

This is presumably because a link hasn't been clicked yet, thus a "view" hasn't been defined yet, but I have no idea how to get around this!

 

I hope I haven't been too vague with my explanation...

 

Thanks,

James

 

Link to comment
https://forums.phpfreaks.com/topic/230161-rather-stuck-using-include-_get/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.