GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 15-Jul-2005, 04:47
dave dave is offline
New Member
 
Join Date: Jul 2005
Posts: 4
dave is on a distinguished road

URL problem in simple Content Management System


Hi to all Ph.P experts,

I am stuck with a problem pertaining to URL and PHP variables.

==========
The Problem.
==========
I am trying to display dynamic content by letting the PHP parser parse PHP variables that point to another PHP file. I haven't even dived into creating a more complete page. I just want to verify if the textbook examples I have learnt works. To my dismay, they don't quite work.

My main page is index.php. I am trying to click on a link indicated by

<a href=test.php?page=testC>Test</a>

to load testC.php. By default, testB.php works when index.php was loaded but when trying to click on the link embedded as a List Item, nothing happens. I want it to display testC.php but it just wouldn't.

Appreciate any help!

===========
index.php file.
===========
PHP Code:

<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Welcome!</title>
<style type="text/css">
body{
    position: absolute;
    top: 5%;
    left: 0%;
    background: url:("images/greybg.jpg");
}
</style>
</head>
<body>
<?
If (empty($page))
{
    $page = "testB";
}
@ require_once ("$page.php");
$navigationmenu = <<<NAVIGATIONMENU
<ul>
    <li><a href=test.php?page=testC>Test</a></li>
</ul>
NAVIGATIONMENU;
print $navigationmenu;
?>
</body>
</html> 


===========
testB.php file.
===========
testB contents.

===========
testC.php file.
===========
testC contents.
Last edited by LuciWiz : 15-Jul-2005 at 06:04. Reason: Please insert your Php code between [php] & [/php] tags
  #2  
Old 15-Jul-2005, 04:49
dave dave is offline
New Member
 
Join Date: Jul 2005
Posts: 4
dave is on a distinguished road

Errata


oops... I'm sorry the "test.php" in

<a href=test.php?page=testC>Test</a>

should be

<a href=index.php?page=testC>Test</a>
  #3  
Old 16-Jul-2005, 06:05
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Hello dave,

Have you figured this out already?

Quote:
Originally Posted by dave
...To my dismay, they don't quite work...
What happened exactly?

Anyway, a much "safer" solution can be found here: http://www.gidforums.com/showthread.php?p=2085... it's an old thread but still relevant.
  #4  
Old 16-Jul-2005, 11:58
dave dave is offline
New Member
 
Join Date: Jul 2005
Posts: 4
dave is on a distinguished road
Smile

Hi JDL,

Thanks for the link. The problem as I mentioned in my original post is that without using $_GET, to display dynamic content simply by using the format

<a href=index.php?page=testC>Test</a>

wouldn't work as $page wouldn't be populated as "testC" when index.php reloads upon clicking the above link. I don't know why it wouldn't work as I followed a text book example for that. Then I read somewhere else that it could be because the "register_globals" directive in php.ini was not set to "on". So curious I was, I went to change it from "off" to "on" but the problem still persists.

However, the link you had provided suggesting the use of $_GET works perfectly fine. Now my CMS can display dynamic content according to what I put after "page=", i.e. I reckon that $page gets populated correctly as index.php reloads. Now everything works! Just that I cannot somehow accept the fact that a text book example failed to work. Not sure if it is due to some things I didn't yet turn on or what.

Anyway thanks for your great help! It's been solved. If you know the answer to the initial problem, I would love to hear it. Once again thanks!

Dave
  #5  
Old 20-Jul-2005, 09:10
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
The book you're using, it may not be something that was published recently.

As you are aware now, the default setting (in php.ini) for register_globals is now OFF; since version 4.2.0 actually, according to the manual. If the book was published before that, then the example was valid at the time but is no longer so.
  #6  
Old 21-Jul-2005, 00:39
dave dave is offline
New Member
 
Join Date: Jul 2005
Posts: 4
dave is on a distinguished road

Thanks.


Thanks JdS!

Quote:
Originally Posted by JdS
The book you're using, it may not be something that was published recently.

As you are aware now, the default setting (in php.ini) for register_globals is now OFF; since version 4.2.0 actually, according to the manual. If the book was published before that, then the example was valid at the time but is no longer so.
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
c simple question problem with switch case if13121 C Programming Language 2 25-Oct-2004 01:06
how do you seo a content management system JUNK KED Search Engine Optimization Forum 4 07-Jun-2004 22:50
RE: A simple update and } problem Dagma20 MySQL / PHP Forum 3 27-Mar-2004 16:37
Content Management HELP! JamesRxx555 Web Design Forum 7 06-Jul-2003 22:48

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:38.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.