php get['cmd'] help

Asked by Harry Smith on 2011-02-03

Hello,

I'm currently in a big mess I am going to be building a website soon in full php and well i have one endless google searches and cant find a solution what i want to do is have the php use the get[''] and have it as get['cmd'] so when I build the navigation system the links will be E.G. index.php?cmd=home and if it is possible that the cmd=home to be linked to a file that gets displayed dynamically on the same page because of that fact this website is going to be fairly big so i will be guessing that a one file website wouldnt be possible unless you think it is each page will have text and images hopefully this is enough info to be able to get help with this as it has done my head in for over 3 hours of endless searches

Thanks

Harry Smith

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu php5 Edit question
Assignee:
No assignee Edit question
Last query:
2011-02-03
Last reply:
2011-02-04
Axel H. (staff-pro-unreal) said : #1

So you like to display a file specified by "index.php?cmd=..."?
Specifically "index.php?cmd=home" should for example display the content of "/home/docs/home.html" inside your page. If this is what you want you can do the following (no sanity chacks here):

<?php

$file = '/home/docs/' . $_GET['cmd'] . '.html';
echo file_get_contents($file);

Can you help with this problem?

Provide an answer of your own, or ask Harry Smith for more information if necessary.

To post a message you must log in.