Problem with coding..
Moderator: General Moderators
Problem with coding..
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
<?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
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
First of all please use the php tag.
The actual thing you need to do is insert the path into the request such as
will get the page in the directory subdir below the top level.
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");
?>Just can't get it work..
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
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
Re: Just can't get it work..
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?randome wrote:Yes, I've tried MANY ways allready, so please give me the whole code as it must put to the site.
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.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Well well
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'm naughty, are you naughty?'>smurf</span> ask money for that? Lick your bulls...or let your mother continue on it.
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'm naughty, are you naughty?'>smurf</span> ask money for that? Lick your bulls...or let your mother continue on it.
Re: Just can't get it work..
please see what you wrote..
viewforum.php?f=26
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...randome wrote: Yes, I've tried MANY ways allready, so please give me the whole code as it must put to the site.
viewforum.php?f=26
Re: Well well
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).randome wrote:You wait me or someone else to pay for your 'help'??
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.
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.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.
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.
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.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.
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).