Problem with coding..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
randome
Forum Newbie
Posts: 3
Joined: Tue Feb 28, 2006 7:31 am

Problem with coding..

Post by randome »

I have a question regarding the php -code below:

<?php
if(!isset($_GET["page"])) { $sivu = "frontpage"; }
else { $page = $_GET["page"]; }
if(!file_exists($page . ".php")) { $page = "error"; }
include($page . ".php");
?>

I read from somewhere that the 'frontpage.php' must be in same directory with index.php, and yes for sure that way it works but..

-----

My question is. How to get 'frontpage' from somewhere else, from other folders? ( then the need is to put/write it only in one place like exemple 'menu.php')

Thank you for the help in advance,

Jarno

ps. if possible, please email me the answer: jarnopalonen@yahoo.com
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

First of all please use the php tag.

The actual thing you need to do is insert the path into the request such as

Code: Select all

<?php

define ('PAGE_PATH'='/subdir/');

if (!isset($_GET["page"])) {
  $sivu = "frontpage"; 
} else { 
  $page = $_GET["page"]; 
}
if (!file_exists(PAGE_PATH . $page . ".php")) {
   $page = "error"; 
} 
include(PAGE_PATH . $page . ".php");
?>
will get the page in the directory subdir below the top level.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

switch the equal on the define line to a comma, however.
randome
Forum Newbie
Posts: 3
Joined: Tue Feb 28, 2006 7:31 am

Just can't get it work..

Post by randome »

How about if someone could make that code just like it need to be in full for my site?

Here are the details;

On top level is directory named 'tarinat', and in there is directory/folder named 'liitteet'

Into index.php of directory 'liitteet' need to get the 'menu.php' from directory/folder 'tarinat'.

Yes, I've tried MANY ways allready, so please give me the whole code as it must put to the site.

Thank you for your co-operation :)
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: Just can't get it work..

Post by Roja »

randome wrote:Yes, I've tried MANY ways allready, so please give me the whole code as it must put to the site.
This is a *learning* site. We help you learn how to do things. Teach a man to fish and he can feed himself for life, ya know?

The alternative (giving you the finished product) is called work. Most people here get paid (a lot) to do that. In most discussions the rate is between $35-$65 US dollars per hour.

I'm sure someone is willing to do it at that rate. If you aren't willing to pay for someone to do work to specification, perhaps you might enjoy learning how to do it yourself, so you can one day charge others.

That service - teaching you a valuable skill - we offer for free here. What a value.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

*going to quote Roja next time this comes up again* :wink:
randome
Forum Newbie
Posts: 3
Joined: Tue Feb 28, 2006 7:31 am

Well well

Post by randome »

You wait me or someone else to pay for your 'help'??

Is that the reason why you're living your life in these kind of places, 'my 10 last years in the forum'? (it can be like this too..the same 'my 10 last years in the toilet')

We've been following people like you're, and all ower the world/Internet. You have NO life outside of these forums. Tell me I'm wrong? No, you can't because I am not wrong.

By the way. I solv the problem abowe. Great a? It wasn't real hard work, just look at it 2 times more and that's it. And you <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> ask money for that? Lick your bulls...or let your mother continue on it.
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

Re: Just can't get it work..

Post by duk »

please see what you wrote..
randome wrote: Yes, I've tried MANY ways allready, so please give me the whole code as it must put to the site.
i think make sense what he said... but you have a section to ask someone to doo your work for free.. but for sure this is not the correct place...

viewforum.php?f=26
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: Well well

Post by Roja »

randome wrote:You wait me or someone else to pay for your 'help'??
Ahem. Read it again - I didn't ask you to pay me. (In fact, I almost never do contract work anymore, because my day job keeps my extremely happy financially).

I enjoy helping people - not working for them. I was making clear to you what the difference was. You weren't asking for help, you were asking people to do work for you.
randome wrote:We've been following people like you're, and all ower the world/Internet. You have NO life outside of these forums. Tell me I'm wrong? No, you can't because I am not wrong.
Personal attacks on members of this forum are not welcome, nor allowed. I happen to have an extremely pleasant life "in real life", far from these forums. I come here to help people, which I enjoy.

Please try to show a little respect for people trying to help others. Its the forum rules, and if you don't like it, please don't visit.
randome wrote:By the way. I solv the problem abowe. Great a? It wasn't real hard work, just look at it 2 times more and that's it.
Great! Glad to hear it. Please help others by following up, and posting what the solution was, so that they can learn from your situation too. Thats how these forums become useful.

I'm sorry you felt insulted by my comments. That wasn't the intent. I wanted you to understand that the forums are here to help people - not do their work for them. (Unless you want to pay people, or ask for volunteers).
Post Reply