• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

I've Searched and searched for this but i can't find it, help would be nice! :)

GoHaN172

New Member
ok i've been looking for a tutorial on this but i cannot find it
for the php scripts, i need to know how to put pages together to use the
filename.php?name=anotherpage

plz plz plz plz help me
 
so i have to put that in for every one that i want to add, say multiple pages

like anotherpage.php
and thatpage.php

i would have to add another variable, right?

and how would i take it from a db?
 
Last edited:
<?php
if (!$page || $page == "") {
include("templates/index.html");
} else {
include("templates/$page.html");
}
?>

this is an example
like - index.php will show templates/index.html
- index.php?page=information will show templates/information.html
...
 
once again I would recommend using ids

here we go

Create a include file called inc.php
PHP:
<?
//inc.php

//Use this var for your pages:

$page[1] = "here.php";
$page[2] = "here1.php";
$page[3] = "here2.php";
$page[4] = "here3.php";
?>

Then create your parser
Say the URL is this:
http://www.here.com/there.php?pageid=1
here would be your parser:
PHP:
<?
//there.php

//includes the pages

include('inc.php')

//gets the variable from the query string

$pageid = @$HTTP_GET_VARS['pageid'];

//checks to see if the query string exsists

if(!$pageid)
{
echo "error";
exit();
}

$address = $page[$pageid];
header('Location:' . $address . '');
?>

the only problem with this code is if you enter an invalid pageid it will produce an error
 
Why not make the other pages html pages?

Let's say we had page1.html and page2.html and we wanted them included.

<?
// We display this if the $page variable is blank.
if(!$page) {
echo "You did not specify a page";
exit;
}
// We display the page here if the $page variable is not blank.
include("$page.html);
?>

lets say the main file is index.php

If I type index.php?page=page1 then it would take me to page1.html
If I type index.php?page=page2 then it would take me to page2.html

However, that would only work if they were all in the same folder. But then that idea would save extra code.

If you did want to make it come from another folder then you could try doing something like index.php?page=images/picture.jpg
 
Originally posted by spec
once again I would recommend using ids

here we go

Create a include file called inc.php
PHP:
<?
//inc.php

//Use this var for your pages:

$page[1] = "here.php";
$page[2] = "here1.php";
$page[3] = "here2.php";
$page[4] = "here3.php";
?>

Then create your parser
Say the URL is this:
http://www.here.com/there.php?pageid=1
here would be your parser:
PHP:
<?
//there.php

//includes the pages

include('inc.php')

//gets the variable from the query string

$pageid = @$HTTP_GET_VARS['pageid'];

//checks to see if the query string exsists

if(!$pageid)
{
echo "error";
exit();
}

$address = $page[$pageid];
header('Location:' . $address . '');
?>

the only problem with this code is if you enter an invalid pageid it will produce an error

are you supossed to put those in the headers of an html file, or do i use notepad or something?
 
No?
errr of course you dont know PHP my bad.
Create a file
called :
inc.php
paste this in there:

PHP:
<?
//inc.php

//Use this var for your pages:

/*these are your pages change here1.php (and all the rest of the heres to what your pages are
*/

$page[1] = "test.html";
$page[2] = "here1.php";
$page[3] = "here2.php";
$page[4] = "here3.php";
?>

next create a PHP file called

specparse.php

and paste this in there:
PHP:
<?
//there.php

//includes the pages

include('inc.php')

//gets the variable from the query string

$pageid = @$HTTP_GET_VARS['pageid'];

//checks to see if the query string exsists

if(!$pageid)
{
echo "error";
exit();
}

$address = $page[$pageid];
header('Location:' . $address . '');
?>

you can create both files using notpad

Lastly create:

test.html

and put this:

<HTML>
<BODY>
Yippy
</BODY>
</HTML>
place all 3 files in the same directory and go here:
www.WHEREVER.com/YOURFILESARE/specparse.php?pageid=1
and see what happens

After you do that
go into inc.php
and edit it the way you want
 
if you have more than 4 pages just add more like so
$page[5] = "THEPAGE.HTML";

and if you have more just add one to the number in the brackets
 
Arrg sorry my bad

Repate this in specparse.php
PHP:
<?
//there.php

//includes the pages

include('inc.php');

//gets the variable from the query string

$pageid = @$HTTP_GET_VARS['pageid'];

//checks to see if the query string exsists

if(!$pageid)
{
echo "error";
exit();
}

$address = $page[$pageid];
header('Location:' . $address . '');
?>
 
thanks man, helped a lot, even tho i don't know anything about php, i'm trying to learn it as we speak, but it's taking a while for me
 
sure

PHP:
if(!$pageid)
{
include('noid.html');
exit();
}
just substitute that for the other if statement and create a HTML page called noid
 
I recommend you wait until I finish my Free Script that will do this but have more power and customization
 
ok, where will it be to download when your done?

^sorry plz disregard this... i hadn't read the other posts, yet, just checked this one^
 
Last edited:
umm, one other question... when i visit other sites and are using this php script (might not be identical) but when i go to their news page (ex: index2.php?page=news) it stays in the address bar as index2.php?page=news... it doesn't change to the hyperlink that it points to, and when u go to the properties it says the same.... so what code am i supossed to use so i am able to have it like that?
 
ok when i was trying out the script you gave me, i'd hyperlink it as index2.php?pageid=blank then the hyperlink would take me to the page http://somewhere.someplace.com/myplace/blank.htm and that's what it changed to in the address bar, but i was at some person's site and when they'd use the the index2.php?page=page it would stay like that in the address bar, it didn't change... can u do it?
 
Back
Top