This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Dreamweaver > January 2005 > PHP link code
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| I am fairly new to PHP i am trying to create an application to:
if a link is clicked and the include it there load it (like a normal like)
if a link is clicked and the file in not there, direct the user to the
404error include.
any help is greatly apreciated
| |
|
|
| Joe Makowiec 2005-01-12, 12:16 pm |
| On 06 Jan 2005 in macromedia.dreamweaver, deey0 wrote:
> I am fairly new to PHP i am trying to create an application to:
> if a link is clicked and the include it there load it (like a
> normal like) if a link is clicked and the file in not there, direct
> the user to the
> 404error include.
If I understand what you want, you want to create a single page; it would
be linked like this:
http://example.com/mypage.php?include=1
http://example.com/mypage.php?include=2
In the page you would have something like:
<?php
// Build the name of the requested file
$includeFile = $_GET["include"] & '.php';
// Get the requested file
include_once{$includeFile);
?>
So that the information in 1.php, 2.php, ... would be included in
mypage.php. If, say, 39.php didn't exist, this would throw an error, or
at least an empty page. Wrap the include statement in a check routine:
<?php
// Build the name of the requested file
$includeFile = $_GET["include"] & '.php';
if (file_exists($includeFile)) {
// Get the requested file
include_once($includeFile);
} else {
include_once('errorfile.php')
}
?>
--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
|
|
|
| | Copyright 2003 - 2009 forum4designers.com Software forum Computer Hardware reviews |
|