What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP Help Wanted (how do I do this: page.php?section=something)

Pages: (2): « First [ 1 ] 2 » Last »
PHP Help Wanted (how do I do this: page.php?section=something)
Author: Message:
rav0
Veteran Member
*****

Avatar
i have an avatar

Posts: 1419
Reputation: 29
35 / Male / Flag
Joined: Aug 2003
O.P. PHP Help Wanted (how do I do this: page.php?section=something)
PHP newbie alert

Often, I see websites that link to the other pages by linking to the same PHP file, but adding different queries. Example: This forum. Every thread is requested from the same showthread.php, but with a different query like ?tid=45715.

How do I do this?

Hope that makes sense. If not, please ask me to clarify.

This post was edited on 06-03-2005 at 04:47 AM by rav0.
| [Image: dorsh] |

(\ /)
(O.o)
(> <)

This is Bunny. Copy Bunny into your signature to help him on his way to world domination
06-03-2005 04:41 AM
Profile E-Mail PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
Joined: Mar 2004
RE: PHP Help Wanted (how do I do this: page.php?section=something)
well this forum uses the tid get value to know what thread to grab from the database , but i think you want to use something really simple like
code:
<?php
$x = isset($_GET['page']) ? $_GET['page'] : 'home';
if($x=='about'){?>
<--- about page html here --->

<? }else if($x=='other'){ ?>

<--- other page html here --->

<?}else{?>

<--- defult page html here --->
<? }?>


so say if someone goes to your page blah.php?page=about it will show <--- about page html here --->
thats for a really simple one though...

This post was edited on 12-21-2005 at 08:39 AM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
06-03-2005 05:06 AM
Profile PM Web Find Quote Report
rav0
Veteran Member
*****

Avatar
i have an avatar

Posts: 1419
Reputation: 29
35 / Male / Flag
Joined: Aug 2003
O.P. RE: RE: PHP Help Wanted (how do I do this: page.php?section=something)
Yes, that's what I wanted, not using my database. Thank you. Have a cookie [Image: cookie.gif]. Hmmm ... that cookie doesn't look that great, have a drumstick as well [Image: drumstick.gif]. I think that I'll use it with  $_REQUEST instaed of $_GET.

[off topic]
Is there a bit of myCode equivalant to <pre>?
[/pff topic]

If the file gets really big, will it slow down the site?

Guido, we need yummy-looking cookies :@:P.

Update: Yay, now I forgot         where I wanted to use this :(.
Update: Yay, now I remember     where I wanted to use this :). Where are my Post-its?

This post was edited on 06-03-2005 at 06:01 AM by rav0.
| [Image: dorsh] |

(\ /)
(O.o)
(> <)

This is Bunny. Copy Bunny into your signature to help him on his way to world domination
06-03-2005 05:38 AM
Profile E-Mail PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: PHP Help Wanted (how do I do this: page.php?section=something)
If the file gets really big, it might slow the server slightly.

And the closest to a BBcode equivalent of <pre> is [code].

This post was edited on 06-03-2005 at 07:10 AM by RaceProUK.
[Image: spartaafk.png]
06-03-2005 07:09 AM
Profile PM Web Find Quote Report
saralk
Veteran Member
*****

Avatar

Posts: 2598
Reputation: 38
35 / Male / Flag
Joined: Feb 2003
RE: PHP Help Wanted (how do I do this: page.php?section=something)
I would do something like this...

code:
<header>
<?php
if (!$a) { $a = "home"; }

include $a.".txt";
?>
<footer>

then have a file for each page, so index.php?a=links would load links.txt in the middle of the page. This way is better i think because you can add new pages without changing the main file.
The Artist Formerly Known As saralk
London · New York · Paris
Est. 1989
06-03-2005 09:02 AM
Profile PM Find Quote Report
Yousef
Full Member
***

Avatar
(previously known as Juzzi)

Posts: 487
Reputation: 19
35 / Male / Flag
Joined: Jul 2004
RE: PHP Help Wanted (how do I do this: page.php?section=something)
quote:
Originally posted by saralk
I would do something like this...

code:
<header>
<?php
if (!$a) { $a = "home"; }

include $a.".txt";
?>
<footer>

then have a file for each page, so index.php?a=links would load links.txt in the middle of the page. This way is better i think because you can add new pages without changing the main file.

It's dangerous to do that. What if I browse to page.php?a=../some_passwd_file
The visitor will be able to access a lot of private files on the server when you use the way saralk suggested, you should build in a protection at least.
Developer of BuddyFuse: Google Talk, Twitter and Hyves in Windows Live Messenger
Ex-Microsoft intern and Windows Live Developer MVP in 2007 & 2008
06-03-2005 09:07 AM
Profile E-Mail PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: PHP Help Wanted (how do I do this: page.php?section=something)
you should put those files in another folder, then they could only do that if they use ../

[code]
<header>
<?php
if (!$a) { $a = "home"; }

include somefolder.$a.".txt";
?>
<footer>

This post was edited on 06-03-2005 at 09:15 AM by Ezra.
[Image: 1-0.png]
             
06-03-2005 09:13 AM
Profile PM Web Find Quote Report
Yousef
Full Member
***

Avatar
(previously known as Juzzi)

Posts: 487
Reputation: 19
35 / Male / Flag
Joined: Jul 2004
RE: PHP Help Wanted (how do I do this: page.php?section=something)
quote:
Originally posted by Ezra
you should put those files in another folder, then they could only do that if they use ../
/www/specialfolder/../../ will still point to /
Developer of BuddyFuse: Google Talk, Twitter and Hyves in Windows Live Messenger
Ex-Microsoft intern and Windows Live Developer MVP in 2007 & 2008
06-03-2005 09:19 AM
Profile E-Mail PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: PHP Help Wanted (how do I do this: page.php?section=something)
I use it on my website too, I have it like this

I hope it's secure else tell me how to make it better :D

code:
function pagina ($page){
   $pad = "paginas/".$page.".php";
   if(!file_exists($pad))
   {
      include("paginas/notfound.php");
   }
   else
   {
      include($pad);
   }
}
if(!isset($_GET["pagina"]) OR $_GET["pagina"] == "")
{
   pagina("home");
}
else
{
   pagina($_GET["pagina"]);
}


Edit: Automatic coloring would be nice :P

This post was edited on 06-03-2005 at 09:30 AM by Ezra.
[Image: 1-0.png]
             
06-03-2005 09:21 AM
Profile PM Web Find Quote Report
Stigmata
Veteran Member
*****



Posts: 3520
Reputation: 45
21 / Other / Flag
Joined: Jul 2003
RE: PHP Help Wanted (how do I do this: page.php?section=something)
ive always done it like this:

code:
<?php
$page = htmlentities($_GET['page']) ;
if (!isset($_GET['page'])) {
include ("home.php");
}
else {
$filename = "pages/$page.php";
if (file_exists($filename)) {   
include("pages/$page.php"); }
else {   
echo "Sorry, The Page Cannot Be Found";}
}
?>

06-03-2005 09:35 AM
Profile PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On