For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > July 2004 > Create a PHP Page Dynamically









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Create a PHP Page Dynamically
Noyb

2004-07-26, 8:55 pm

Xref: 127.0.0.1 alt.php:11392 comp.lang.php:24443 alt.comp.lang.php:6565

Is it possible to create a php page dynaimically? For example, when a
user is added I'd like to create a page in a directory in their name so
users could go to www.mysite.com/jack or www.mysite.com/jill and
index.php will have been created there. I know there are many ways
around this but I'd like to know if a php page can be created on the
server. Thanks.
Steve.
Nik Coughin

2004-07-26, 8:55 pm

Noyb wrote:
> Is it possible to create a php page dynaimically? For example, when a
> user is added I'd like to create a page in a directory in their name
> so users could go to www.mysite.com/jack or www.mysite.com/jill and
> index.php will have been created there. I know there are many ways
> around this but I'd like to know if a php page can be created on the
> server. Thanks.
> Steve.


Yes.

http://www.php.net/manual/en/ref.filesystem.php



Gordon Burditt

2004-07-27, 3:56 am

>Is it possible to create a php page dynaimically? For example, when a
>user is added I'd like to create a page in a directory in their name so
>users could go to www.mysite.com/jack or www.mysite.com/jill and
>index.php will have been created there. I know there are many ways
>around this but I'd like to know if a php page can be created on the
>server. Thanks.


You can write one PHP page that does all sorts of stuff depending
on how it is called. For example, it looks at what name it was
called under, looks this up in a database, and spits out a page for
the user based on his entries there. This works best if the pages
follow a pattern rather than being completely free-form. For
example, I suspect that Ebay item-for-sale pages are generated out
of a template, with some seller-supplied pieces, including text,
html, and maybe a few images (or at the very least, links to images
hosted elsewhere). (I have no idea whether Ebay uses PHP, though).

Yes, you can create files in the document tree, if permissions are
set up to do this. I'd be REALLY, REALLY careful about letting
users create PHP pages which can ALSO write on the filesystem: it's
very easy to open up security holes this way. See fopen(), for
example, with a filename argument, if you really want to do this.

Gordon L. Burditt
Noyb

2004-07-27, 3:56 am

Xref: 127.0.0.1 alt.php:11402 comp.lang.php:24452 alt.comp.lang.php:6571

Gordon Burditt wrote:

>
>
> You can write one PHP page that does all sorts of stuff depending
> on how it is called. For example, it looks at what name it was
> called under, looks this up in a database, and spits out a page for
> the user based on his entries there. This works best if the pages
> follow a pattern rather than being completely free-form. For
> example, I suspect that Ebay item-for-sale pages are generated out
> of a template, with some seller-supplied pieces, including text,
> html, and maybe a few images (or at the very least, links to images
> hosted elsewhere). (I have no idea whether Ebay uses PHP, though).
>
> Yes, you can create files in the document tree, if permissions are
> set up to do this. I'd be REALLY, REALLY careful about letting
> users create PHP pages which can ALSO write on the filesystem: it's
> very easy to open up security holes this way. See fopen(), for
> example, with a filename argument, if you really want to do this.
>
> Gordon L. Burditt


Thanks Gordon. I understand what you're talking about but the
convenience of telling people to go to www.mysite.com/jack is what I was
looking for. The answer posted by Nik C.
(http://www.php.net/manual/en/ref.filesystem.php) is just what I was
looking for in case anyone else out there is wondering.
Noyb

2004-07-27, 3:56 am

Xref: 127.0.0.1 alt.php:11404 comp.lang.php:24453 alt.comp.lang.php:6572

Nik Coughin wrote:

> Noyb wrote:
>
>
>
> Yes.
>
> http://www.php.net/manual/en/ref.filesystem.php
>
>
>

Thanks Nik!
Markus Ernst

2004-07-27, 8:56 am

"Noyb" <none@hotmail.com> schrieb im Newsbeitrag
news:v7hNc.17404$Qu5.3560@newsread2.news.pas.earthlink.net...
> Is it possible to create a php page dynaimically? For example, when a
> user is added I'd like to create a page in a directory in their name so
> users could go to www.mysite.com/jack or www.mysite.com/jill and
> index.php will have been created there. I know there are many ways
> around this but I'd like to know if a php page can be created on the
> server. Thanks.
> Steve.


Alternatively to what Nik and Gordon pointed you to, you could also
- Use mod_rewrite (with a .htaccess file) to redirect all requests to
/index.php
- analyze the address entered:

$url_array = explode("/",$_SERVER['REQUEST_URI']);
$who = $url_array[1];

So if somebody called www.mysite.com/jack $who is now set to "jack", and you
can use this to get jack's data from your database, file or whatever.

HTH
Markus


Savut

2004-07-27, 3:58 pm


"Markus Ernst" <derernst@NO#SP#AMgmx.ch> wrote in message
news:41061daf$0$456$afc38c87@news.easynet.ch...
> "Noyb" <none@hotmail.com> schrieb im Newsbeitrag
> news:v7hNc.17404$Qu5.3560@newsread2.news.pas.earthlink.net...
>
> Alternatively to what Nik and Gordon pointed you to, you could also
> - Use mod_rewrite (with a .htaccess file) to redirect all requests to
> /index.php


"DocumentIndex index.php" would be better and faster

Savut
http://ww.savut.com

> - analyze the address entered:
>
> $url_array = explode("/",$_SERVER['REQUEST_URI']);
> $who = $url_array[1];
>
> So if somebody called www.mysite.com/jack $who is now set to "jack", and
> you
> can use this to get jack's data from your database, file or whatever.
>
> HTH
> Markus
>
>


Noyb

2004-07-27, 3:58 pm

Xref: 127.0.0.1 alt.php:11427 comp.lang.php:24511 alt.comp.lang.php:6592

Savut wrote:
>
> "Markus Ernst" <derernst@NO#SP#AMgmx.ch> wrote in message
> news:41061daf$0$456$afc38c87@news.easynet.ch...
>
>
>
> "DocumentIndex index.php" would be better and faster
>
> Savut
> http://ww.savut.com
>
>


Thanks Markus and Savut!
eclipsboi

2004-07-27, 8:55 pm

On Tue, 27 Jul 2004 08:36:05 -0400, "Savut" <webki@hotmail.com> wrote:

>
>"DocumentIndex index.php" would be better and faster

DocumentIndex does not exist in either 1.3 or 2.0 of Apache.
DirectoryIndex and DocumentRoot do, but respectively either determine
the default file to display if none is called, or set the base web
directory for the domain (the latter only being set in the server
config file globally, or via a <VirtualHost> directive.

What this guy wants is in essence, virtual directories. Similar to how
Yahoo Profiles does it (I presume). A way to have virtually infinite
directories, without the physical directories.
Savut

2004-07-28, 3:56 pm

Then mod_rewrite would do the job perfectly

Savut
http://www.savut.com

"eclipsboi" <eclipsboi@hotmail.com> wrote in message
news:7lddg0pqk0nuvllr6qv3h1lkgtjovr8h71@
4ax.com...
> On Tue, 27 Jul 2004 08:36:05 -0400, "Savut" <webki@hotmail.com> wrote:
>
> DocumentIndex does not exist in either 1.3 or 2.0 of Apache.
> DirectoryIndex and DocumentRoot do, but respectively either determine
> the default file to display if none is called, or set the base web
> directory for the domain (the latter only being set in the server
> config file globally, or via a <VirtualHost> directive.
>
> What this guy wants is in essence, virtual directories. Similar to how
> Yahoo Profiles does it (I presume). A way to have virtually infinite
> directories, without the physical directories.


Hostmaster \(NS\)

2004-07-28, 3:56 pm

just have a script create the virtual host and then copy a index.php =
into their home dir or echo the php code into a php file


"Noyb" <none@hotmail.com> wrote in message =
news:v7hNc.17404$Qu5.3560@newsread2.news.pas.earthlink.net...
> Is it possible to create a php page dynaimically? For example, when a=20
> user is added I'd like to create a page in a directory in their name =

so=20
> users could go to www.mysite.com/jack or www.mysite.com/jill and=20
> index.php will have been created there. I know there are many ways=20
> around this but I'd like to know if a php page can be created on the=20
> server. Thanks.
> Steve.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com