Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

99 users online



Tutorial: page.php?page=blah / query strings / easy template tutorial (UPDATED)

Tutorial: page.php?page=blah / query strings / easy template tutorial (UPDATED)

Currently viewing this thread: 1 (0 members and 1 guests)


Page 2 out of 15
Jeb

Jeb

Status: Offline!

Re: The ultimate page.php?page=blah / query strings / easy template tutorial

Quote:

Originally posted by Ares
Now, something that will cause many of you problems is register_globals. If its on, using $queryStringVar when going to page.php?queryStringVar=tom wont print out anything.

Ares, quick note.

register_globals ON means that $queryStringVar will be set.

register_globals OFF means that it will not be set.

Just a little inconsistency some people might get conf00zed by Smile

___________________

Adam Goossens -- PHP is my mother tounge.

Linux: ( kernel.org | winehq ) -- f33l the p0w3r.

Nobody replying to your questions? Getting flamed? Getting told to RTFM? Ask your questions the right way.

RedLeo

RedLeo

Status: Offline!
Quote:

Originally posted by Jeb.
Try replacing $_GET with $HTTP_GET_VARS.

If that doesn't work, I'm stumped.


Awesome, it works! Thanks Jeb!

___________________

I like pie.

Dan1

Dan1

TF Retiree
Status: Offline!

Why use switch and not include? I don't see what's wrong with it, unless there's a security bug somewhere. And, aren't vars supposed to begin with a letter, or was that just CSS..

Edit: Also, it would probably be better not to use XHTML in your code, since if their doctypes and such are wrong, it may cause errors at some point.

Edit2: If none of that made sense, basically I'm trying to say that switches have too much extra syntax.

Last edited by Dan1, March 25th, 2003 11:43 AM (Edited 1 times)

CDude

CDude

nothing
Status: Offline!

<? print '<? XML...blah ?>'; ?>

___________________

http://celerondude.com

DirectWD

DirectWD

Status: Offline!

heh.. $1337 should be $_1337

___________________

» DirectWD HTML / JavaScript / XHTML / CSS / PHP / MySQL
Direct Web Design

KungPaoChicken

KungPaoChicken

Status: Offline!

If your lazy like me, heres code for dynamic includes.
*.php?page=*.php
This is 100% secure to my knoledge, all pages must be .php and be in THE BASE DIR! meaning you CAN NOT include /forums/index.php or /info/stuff.php but has to be whatever.php Enojy if you want to use it. Ill post another one i wrote that is also secure later.

PHP:

<?php

if (isset($_GET['page']) && is_file(basename($_GET['page']))) {
    include(
basename($_GET['page']));
} else {
    include(
basename('404.php'));
}

?>

___________________

i stupended my own signarture

S3pyh

S3pyh

Status: Offline!

please help

Please help me!

I am trying to figure out these query strings for about a week now ive really been looking for things but none of them have fixed my problem!

How do i do it so when it tells it to goto page=test it only uses the code in test.php?

every page ive tryed and all the code ive tryed the pages just overlap each other and the page/text is included twice!

The problem i think is that im including a page into a page but i don't know how to get around that.

Thanks for any help, its hard to explain, if you need any code or anything or to post my test pages of my site i can do so. but i didn't really want to post the url for everyone to see, maybe i can PM.

___________________

http://www.code-9.com/Code-9logo.gif

Dan1

Dan1

TF Retiree
Status: Offline!

If you could post an example I'd be glad to take a look.

S3pyh

S3pyh

Status: Offline!

LOL after SO MANY HOURS ive worked it out and its so newbieish what it was.

I do know quite alot of php and have been building my site (http://www.code-9.com) for quite some time now.

You guys should really make clear all the query code needs to be in a TOTALLY SEPERATE PHP FILE to everything else. THIS IS REALLY WHAT I THINK PEOPLE ARE GETTING WRONG!

Iwas putting this code into my index/home.php and thats why it was f***ing up.

I feel such a newb now but you live and learn!

___________________

http://www.code-9.com/Code-9logo.gif

JohnSaunders

JohnSaunders

Neverside Newbie
Status: Offline!

So what would be the best way for the code below to print sub navigation links on a page then for the page that is being viewed, do not display the hyperlink.

PHP:

<?php
if ($_GET["page"] == "resume") {
    print 
"<p class=\"subnav\">Resume</p>";
} else {
    print 
"<p class=\"subnav\"><a href=\"about_me/resume/\">Resume</a></p>";
}

if (
$_GET["page"] == "interests") {
    print 
"<p class=\"subnav\">Interests</p>";
} else {
    print 
"<p class=\"subnav\"><img src<a href=\"about_me/interests/\">Interests</a></p>";
}
?>

What is the difference between using if/else statements and case/break?

___________________

Best Regards,

John Saunders

Page 2 out of 15
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.011 seconds.