Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i auto create a webpage with username as its filename?

Status
Not open for further replies.

tippytarka

Programmer
Jul 19, 2004
115
GB
hi,

i'm trying to get my head around the better way to put together member profile pages for a dating website... having reviewed a few dating sites i've noticed that they have usernames or account id's appended to the urls of their member profile pages... for instance...
so my questions are...

1) do websites actually have a directory with all these member profile pages each with a unique username as its filename? if they do there would thousands

2) If this is the way that its done... then what is a good approach to creating a script that would automatically create a web page with the username as its filename... for example username.php , and place it into a designated directory ...when the user signs up.

3) or, is it done by using a database and script and not actually auto creating the pages in a directory? i guess if you type the url in the address bar then the actual profile web page has to exist in the directory?
 
good question.

i'd guess they use mod_rewrite and pass the user name to the redirected script as an argument.
 
ok, i'll read up on mod_rewrite any more recommendations are welcome
 
then mod_rewrite is going to be difficult...
i suspect the other dating sites that employ this method are running apache. is there any reason why you can not?

you can, of course, do this a few other ways too. the easiest would be to cheat a little on your url constraints and have the url being
Code:
[URL unfurl="true"]www.somedatingsite.com?u=username[/URL]
and use the query parameter of u to pass the username to a switchboard on your landing page, which would then direct php to the right information to bung out. this is what i was going to suggest as the mod_rewrite rule for you to employ.
 
hi jpadie, i'm using a hosting service and not my own server.

can you elaborate more on your latest reply... "use the query parameter of u to pass the username to a switchboard on your landing page
 
Just like jpadie said. Add "?u=username" to your url and on your php script lookup page, $_GET("u") will tell you the value sent to the script.
 
ok, so when a person types in in the url address... it goes to a lookup script that direct them to the correct profile page...

sound like a good idea that i didn't think of. so by placing ....?u=username at the end of the url the '?' is the ref id that is picked up in the lookup switchboard script?? haven't really used ref ids in urls before
 
1) do websites actually have a directory with all these member profile pages each with a unique username as its filename? if they do there would thousands
I very much doubt if this is the way anyone has programmed it, because as the user base grows so does the number of profile pages (as you pointed out). This wouldn't be a very efficient way of doing it.

3) or, is it done by using a database and script and not actually auto creating the pages in a directory?
I would suggest this is the way to implement it. Use the suggestions above to pass the username to the script via the url, pick it up using GET as Miros mentioned, plug it into a SQL query to extract the data for that user from the database - and format the returned data as appropriate.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Code:
ok, so when a person types in [URL unfurl="true"]www.somedatingsite.com?u=username[/URL] in the url address... it goes to a lookup script that direct them to the correct profile page...

Exactly. Or as Clive said, pulls the info from a SQL database and displays it.

Code:
sound like a good idea that i didn't think of. so by placing ....?u=username at the end of the url the '?' is the ref id that is picked up in the lookup switchboard script?? haven't really used ref ids in urls before

Actually, ? is the punctuation that lets the web browser and webserver differentiate between the file name and the parameters. 'u=' is actually the "ref id."

And once your data is in a database, you can do searches like "age=35", not just u=MaryJones.
 
cheers! sorted guys. i'm surprised i couldn't see the obvious
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top