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]

Author PHP link code
deey0

2005-01-10, 7:16 pm

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

SnakEyez

2005-01-10, 7:16 pm

What you are looking for has nothing to do with PHP. It has to do with .htaccess files. Check out this link:

http://www.javascriptkit.com/howto/htaccess.shtml
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
Sponsored Links


Copyright 2003 - 2009 forum4designers.com  Software forum  Computer Hardware reviews