Jump to content


Photo

URL variables


  • Please log in to reply
2 replies to this topic

#1 fallenone1884

fallenone1884
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 12 September 2006 - 09:10 AM

Im trying to update my site using php, so learning as i go with simple functions and scripts, i have a question regarding a URL variable get command (think thats what its called)

The majority of the code works fine with no problems, issues i am having are when i try and get from another directory, or when calling on a php script like phpbb2.

right now i have my page seperated into two frames, one which i use for the link menu and banner image and the "body" frame which i direct all my links to.

I would like to keep this setup, but want to get rid of the frames, most of the url variable get functions work correctly. its just when i try and get something that resides in another directory, or as i said above something like phpbb2.

i tried a work around for the forum issue with phpbb2 making a forum.php file and doing an include in that file and using the url variable to call that

www.myhost.com/index.php?page=forum

and it will pull the page up, and place it in the body, but the style is gone, aas well as any images ect...

I dont know if ive been clear or just rambled, let me know, i would like to see this work, or some idea's on how to handle this situation.

Thanks

#2 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 12 September 2006 - 09:38 AM

A little rambly :)  I'll try to clarify some things

Can you give more detail about what "get from another directory" means?  Are you talking about forms, eg <form method=get>, or about links, eg <a href="page.php?var=value">?  Or something else?

Also, are you using cookies or sessions (or neither)?

#3 fallenone1884

fallenone1884
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 12 September 2006 - 09:57 AM

This is the coding i would like to use and is what i mean by the get function

$p = $_GET["page"];

im not using cookies or sessions

and as i said, it will load the php pages that reside in the same dir. as the code below, well i beleive it will load any directory as long as i type it that way

www.myhost.com/index.php?page=pages/hello/mine/gold

like above

but its not loading the images ect along with the content, as i can see the image paths are getting lost or rather being changed to the url of the path of this script

so instead of myhost.com/forum/pictures

its making it myhost.com/pictures

and then none of the links work in the forum, because i am assuming, they are no longer relative to the current path

<?php 
require "fcbanner.php";

require "menu.php";

?>

<?php
$p = $_GET["page"];
if (strpos($p,"..")) {
    die("Bad page request");
}
if (!$p) $p = "main2";
$content_file=$_SERVER["DOCUMENT_ROOT"]."/".$p.".php";
if (!file_exists($content_file)) {
    header("Location: {$_SERVER["PHP_SELF"]}");
    exit();
}
// Syntax: $variable = (condition) ? value_if_true : value_if_false;
$title = ($p) ? "$p - Fated Chaos" : "Main page - Fated Chaos";
include("header.php");
include($content_file);
include("footer.php");
?>
 
<?php
include("http://www.fatedchaos.com/Forum/index.php");
include("http://www.fatedchaos.com/counter/phpcounter.php");
include("webring.php"); 
include("copyright.php"); 

?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users