I am currently developing a site written in primarily PHP that allows users to signup and enter in some information. I would like to give them a unique url (web page) on my site that contains their information so it can be favorited, or quickly accessed by them. Do I need to create a folder in the virtual directory for each user ?
How do I give each registered user their own url using php?
Collapse
X
-
Hi,
You could use url rewrites. (second time i mentioned this today!).
Anyway basically you make your page work using querystrings...
e.g. domain.com/index.php?user= harshmaul
and then you rewrite it to this....
domain.com/harshmaul/
Is that what you going for?
If thats what you want,check out mod rewrites in the htaccess. -
I believe you can create a script to create a folder with the unique username as the name of the folder, and user-specific content (e.g. pictures) place therein.Originally posted by jtmphpI am currently developing a site written in primarily PHP that allows users to signup and enter in some information. I would like to give them a unique url (web page) on my site that contains their information so it can be favorited, or quickly accessed by them. Do I need to create a folder in the virtual directory for each user ?
On the other hand, there may be a couple of advantages in creating the page 'on the fly', by constructing an SQL to draw user-specific information into the user's page from a database, like so:
Code:<?php $sql="SELECT * FROM users_table WHERE user_id=".$id; $query=mysql_query($sql); $row_query=mysql_fetch_assoc($query); ?><html> <head> <title>My Site Home Page for <?php echo $username ?></title> </head> <body> <h1>Welcome to <?php echo $username?>'s Home Page!</h1> <div>Some stuff...</div> <div>Some other stuff...</div> </body> </html>
Comment
-
missed out code tags oops
hi,
are you still running apache? cos the rewrites are done using that....
in the root of your website (htdocs folder)...
create a file called...
".htaccess"
then in that file write the following....
this will rewrite all pages that go likeCode:RewriteEngine on RewriteRule ^([.*])/$ index.php?login=$1
to
does that help?Comment
-
Hi jtm, rather than giving a solution, I'll ask a question !Originally posted by jtmphpI am currently developing a site written in primarily PHP that allows users to signup and enter in some information. I would like to give them a unique url (web page) on my site that contains their information so it can be favorited, or quickly accessed by them. Do I need to create a folder in the virtual directory for each user ?
if you are still planning to create separate directories for each user, do you planing to put individual pages for them on those directories?
ex:
http://www.domain.com/user_dir1/
http://www.domain.com/user_dir2/
is there separate web pages in those directories, for the users?
I think the most easiest solution has already provided for you.Comment
-
But the heaviest..Originally posted by ak1dnarHi jtm, rather than giving a solution, I'll ask a question !
if you are still planning to create separate directories for each user, do you planing to put individual pages for them on those directories?
ex:
http://www.domain.com/user_dir1/
http://www.domain.com/user_dir2/
is there separate web pages in those directories, for the users?
I think the most easiest solution has already provided for you.
imagine 4000 people do this.. that's 4000 folders, with 4000files, and possibly 4000 images and other content!
If you do this dynamically it saves you alot of hassle.Comment
-
I want to allow the user's url to be accessed by other members if given the link. So I won't be able to create it on the fly because it won't be based on the user that is signed on. Looking for something similar to how myspace lets it's users create a url page that can be hit directly without signing in. I assume when the user signs up I would create a folder/page at that point. Not sure how to do that.Comment
-
I'm sorry. I forgot to say I'm running IIS on WinXp Sp2 on my primary developing machine, and I'd love to be able to achieve the url rewrite kind of thing on this system. However, thanks all the same, 'cause I intend to use the info you supplied on another system running apache on WinXp Sp2.Originally posted by harshmaulhi,
are you still running apache? cos the rewrites are done using that....
in the root of your website (htdocs folder)...
create a file called...
".htaccess"
then in that file write the following....
this will rewrite all pages that go likeCode:RewriteEngine on RewriteRule ^([.*])/$ index.php?login=$1
www.domain.com/mylogin/
to
www.domain.com/index.php?login =mylogin
does that help?
Thanks and regards,
Ifedi.Comment
Comment