Cheap Gas - Credit Card Consolidation - Mobile Phone - Internet Marketing
php page generator? [Archive] - Threeboy Forums

PDA

View Full Version : php page generator?


Kentor
06-16-2004, 12:33 AM
I see a lot of sites with ".php?=page" in the url and I was wondering how the heck do you do that?

I heard from my friend that it's like a page generator :confused: (which I don't get)

And is it better than just creating different .php files for different pages?

I might start a site if I learn how to do that :beer:

SileNceR
06-16-2004, 03:58 AM
basically you have a php page which, depending on the value passed to it, gets information from somewhere (wherever u want) and displays it to the client browser
this allows u to pull all ur sites content from, for example, a live database, making it easier to update the site and or to ad new content etc...

you could also pull variables like colors or logos from arrays, or also from databases, for things like flavours (see spoono.com for an example of that)

u COULD use this method to pull info from static files but then, the server will need to interpret the php, and pull in the info from the file to display, in which case, since its static info u may as well make seperate pages -- but THEN, you need to change every page if u want to change design....

SSI can fix this, kinda in a reverse way to php, in ssi u have to put include at the start and end of the document and have a page header and footer..., in php you can have all ur design code in the one php document, and then have all ur content in seperate files, or as i said before a database, and then just pull the content into the pages as you need it... doing it with php also means u can perform complex calculations if the need be, or do other cool things.... (u can get the server date for example, or program in comments features etc etc...)

Kentor
06-16-2004, 12:58 PM
Can you give me a code to test it out? Or is it way too long?

chrisv
06-16-2004, 02:47 PM
http://www.php.net/ has a ton of information and people link to some good tutorials.

Kentor
06-16-2004, 03:13 PM
That place is hell : \ I couldn't find "php page generators" if i tried

SileNceR
06-16-2004, 07:08 PM
hehe

depends what u want

with ssi, u'd have ur header and footer code in seperate pages-

header.inc:
<html><head>...<design code here><table cell here>

then u'd use (i forget the proper code) <ssi include="header.inc">
<page content>
<ssi include="footer.inc">

footer.inc would be like:
</close table></body></html> and all that...

and each separate content page would be .shtml and contain the header and footer "includes"

whereas in php... (probably not working code, havent got time for that)
there are a few ways, databasing - which i can't really show here, or static files, same as above SSI but nicer to work with, since php can actually write to static files, or databases so you can update ur site from part of ur design

<html>
<head><title>
<?php include("title$page.inc"); ?>
</title></head>
<page design here>
<table cell start>
<?php
include("content$page.inc");
?>
</table>
<? include ("copyright.inc"); ?>
</body></html> etc etc

there are plenty of ways to do it, but in that example u could edit the design page still using a web editor and save it, upload it etc making it easier to make minor or major design changes (use CSS for all ur text formatting too, this way u can change fonts, colors etc without needing to edit all your content pages)

this way, tho, all ur links are basically done as:

(for this example we'll say you have a page for photos, which u number 17 -- if you use words people could enter ../../../etc/passwd etc and get system configurations, if u use numbers, u can do some code to check at the top of ur page if $page == a number, and if not to display the index page, or an error page)

so content17.inc contains the data to go on that sub-page
title17.inc contains say... "Photos 2003-2004"
copyright.inc contains say "this page &copy; copyright 2004 kentor designs"

ur link to photos would be <?php echo "<a href=\"$PHP_SELF?page=17\">Photos</a>" ?>


obviously it's a little more complicated and there are other error checks you need to run to make sure no-one is trying to jump around ur design, and my code is probably a little messy, i ahvent programmed much since about october last year... hope this helps; download the manual from php.net and use this as it has many code examples for every, or nearly every command within php.

Kentor
06-16-2004, 08:14 PM
Ey, I love you man!

But i have some questions: where do I put the if == page thingy? And why'd you use .inc, i used .php and its workin just as well

SileNceR
06-19-2004, 06:41 AM
u can use what you want, usually i use .inc as it's easier for me to tell which files are included etc, and then if ppl try to open those files by name no html should be processed...

i'd put the if == page thing near the top, theres a php command either break or stop which stops a page from running any more code after that command...

so if(isnumber($page)){}else{print 'no content available to match your request'; stop}

not sure on isnumber, or stop... check in the php manual

Kentor
06-19-2004, 10:02 AM
u can use what you want, usually i use .inc as it's easier for me to tell which files are included etc, and then if ppl try to open those files by name no html should be processed...

i'd put the if == page thing near the top, theres a php command either break or stop which stops a page from running any more code after that command...

so if(isnumber($page)){}else{print 'no content available to match your request'; stop}

not sure on isnumber, or stop... check in the php manual

Gotcha.

SileNceR
06-20-2004, 02:06 AM
if you've got MSN add me silencer_rh@hotmail.com, that way if u have any more questions I can fire back straight away if im online...

zubaz
06-24-2004, 05:23 AM
just so you know - that method of php page generation is super unwieldy. There's really no reason to use it, at least no to the extent that some sites do.

irtsert
06-25-2004, 03:20 PM
How come the ?page= thing doesn't work on my own web server? It works on other servers. My server seems to ignore the variable after the " ? " .

Anyone can help me?

Threeboy
06-26-2004, 01:35 AM
just so you know - that method of php page generation is super unwieldy. There's really no reason to use it, at least no to the extent that some sites do.
it facilitates lazyness...

it's also bad for older search engines.

SileNceR
06-26-2004, 01:42 AM
if it draws from a database and the site is updatable life then theres reason to use it but if its being used soley to be like "omg im using php" then a site would be better off using CSS and SSI... IMO @ least...

and irtsert: you should check with your hosts as some disable automatic registration of URL parsed information being globally declared, search the PHP manual for HTTP_GET_VARS and HTTP_POST_VARS (get is what you're after, but post is involved if you are using forms and not the URL)

irtsert
06-26-2004, 09:51 AM
thanks SileNceR , I changed my php.ini file and turned register_globals on, now it works on my apache server. However, it doesn't work on IIS, and phpinfo() shows that in IIS, register_globals is still off!! Is there a way to solve this?

irtsert
06-26-2004, 11:08 AM
nevermind I solved the problem
It was a NT permission problem

SileNceR
06-27-2004, 02:57 AM
I was going to say that php.ini should be the same for both...
but stick with apache :D anyway...

zubaz
07-01-2004, 06:46 PM
thanks SileNceR , I changed my php.ini file and turned register_globals on, now it works on my apache server. However, it doesn't work on IIS, and phpinfo() shows that in IIS, register_globals is still off!! Is there a way to solve this?
IIS keeps its own copy of php.ini in the Windows directory if I remember correctly. Just do a search for the filename.

Agent40
09-07-2004, 02:41 PM
http://www.bitmonkeys.com/showthread.php?t=24

that post helped me out

Mark
10-12-2004, 07:38 PM
That is one way to do it. Another way to do is if you are writing articles for, say, a news website, and you want every article to have an id, then when you post that information into your mysql database, have the id field auto-incremented. Although you probably got lost right there. ;)