Jump to content

Links Array


guitarboy8d6

Recommended Posts

ok I'm fairly new at php and have been trying to do a site for my mom that she can edit on her own. So I created a file par.php that holds several diffrent includes mainly for style stuff, and content. One of my thing in there is this

<?
$page[home]="index.php";
$page[services]="services.php";
$page[health]="health";
$page[eff]="effciency.php";
$page[about]="aboutus.php";
$page[contact]="contact.php";

$display=$_GET['page'];

file_get_contents ($display);

?>

I have the browser send a uri of [a href=\"http://www.flairandheat.com/par.php?page=contact\" target=\"_blank\"]http://www.flairandheat.com/par.php?page=contact[/a] to try and open the contents of the contact page. But I get the following Error.

Warning: file_get_contents(contact): failed to open stream: No such file or directory in /home/flairandheat.com/www/flairandheat.com/phpsite/par.php on line 17

contact.php is in the directory and if you browse to it, you basicly see some text that I want to be displayed where I placed the script.

I have a links file that is included on everypage that looks like this.

<div class="nav"> <a href="index.php">home</a> | <a href="par.php?page=services">services</a> | <a href="health.php">health</a> | <a href="efficiency.php">efficiency</a> | <a href="aboutus.php">about us</a> | <a href="par.php?page=contact">contact us</a></div>

The only file that exestist though is contact.php because I didn't want to go through the trouble of making all the pages if I couldn't get this to work.

I am basicly looking for a way to get par.php to display the contents of the files set in the array. I'm not sure were to go to get it working right. I am open to any suggestions that people have and if you can kinda explain why it works that would be great too.
Link to comment
Share on other sites

[code]<?php

$page['home']="index.php";
$page['services']="services.php";
$page['health']="health";
$page['eff']="effciency.php";
$page['about']="aboutus.php";
$page['contact']="contact.php";

if (isset($page[$_GET['page']])) {
    $content = file_get_contents ($page[$_GET['page']]);
}
else {
      $content = '';
}

?>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.