473,287 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

How do I give each registered user their own url using php?

9
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 ?
Feb 11 '08 #1
11 6612
harshmaul
490 Expert 256MB
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.
Feb 11 '08 #2
ifedi
60
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 ?
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.
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:
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $sql="SELECT * FROM users_table WHERE user_id=".$id;
  3. $query=mysql_query($sql);
  4. $row_query=mysql_fetch_assoc($query);
  5. ?><html>
  6. <head>
  7. <title>My Site Home Page for <?php echo $username ?></title>
  8. </head>
  9. <body>
  10. <h1>Welcome to <?php echo $username?>'s Home Page!</h1>
  11. <div>Some stuff...</div>
  12. <div>Some other stuff...</div>
  13. </body>
  14. </html>
  15.  
Feb 12 '08 #3
harshmaul
490 Expert 256MB
Hi,
Ifedi has written some good logic. if you do get the page working using a "on the fly page" via the querystring as i mentioned above. we can re-write these into what appears to be a subfolder for that user.
Feb 12 '08 #4
ifedi
60
If thats what you want,check out mod rewrites in the htaccess.
For those of us on Windows platform, how do we do the url rewrite?
Feb 12 '08 #5
harshmaul
490 Expert 256MB
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....

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2. RewriteRule ^([.*])/$ index.php?login=$1
this will rewrite all pages that go like
www.domain.com/mylogin/
to
www.domain.com/index.php?login=mylogin

does that help?
Feb 12 '08 #6
ak1dnar
1,584 Expert 1GB
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 ?
Hi 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.
Feb 12 '08 #7
Markus
6,050 Expert 4TB
Hi 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.
But the heaviest..
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.
Feb 12 '08 #8
jtmphp
9
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.
Feb 12 '08 #9
harshmaul
490 Expert 256MB
Hi,
Thats fine, the user doesn't need to be logged in for you to use url rewriting.
you just send someone the link to .../index.php?name=myLogin, and if you just use that query string variable to display the page for that user.
Feb 12 '08 #10
ifedi
60
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....

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2. RewriteRule ^([.*])/$ index.php?login=$1
this will rewrite all pages that go like
www.domain.com/mylogin/
to
www.domain.com/index.php?login=mylogin

does that help?
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.
Thanks and regards,
Ifedi.
Feb 12 '08 #11
jtmphp
9
Thanks all for your replies. I am going to try the rewrite.
Feb 12 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: RT | last post by:
I have followed the step by step instructions in the login manual Created login page Use LSC01 This works - login and get redirected to the proper page My problem is the cookie variables...
0
by: Colin | last post by:
"There is no object in this control" in Access 97 form with registered MSINET.OCX on XP machine I have an Access 97 database that I made a form with using the Microsoft Internet Transfer control...
3
by: arthur-e | last post by:
A new Machine was set up by our IS department - it came with Office Pro 2003. Access97, Word97 and Excel 97 were added. I'm trying to update an Access 97database to 2003 but get weird compiling...
2
by: Patrick Blackman | last post by:
How do you determine the registered company on a computer? Thanks Patrick.
1
by: Matthew Louden | last post by:
I guess this is more likely the user problem, but don't know how to fix. For regular server-side programs without using data access or ADO, there is no run-time error. I really have no idea why it...
1
by: Jen | last post by:
Hi, I'm having an issue calling a dll from an ASP.NET page. The code that tries to instantiate a COM dll (class) is in a Class Library. I can call the code successfully from a windows...
0
by: Rob Schieber | last post by:
Hello All, I am currently having an issue running an assembly registered using regasm in process under IIS. I wrote the component in C#, then used regasm to register the assembly. All is well...
11
by: Prince of Code | last post by:
Hey There, I have been to this group for a couple of days. I am really impressed by the way people respond. I get answers for all my doubts and that too more info. So I am putting across a doubt...
9
by: DKn | last post by:
Hi , I am having a .Net Activex control. I have done coding for COMRegistering and Unregistereing in C#.Net. The code is follows.. static void ComRegister(Type t) { ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.