How to create user profile like this www.abc.com/user1

Discussion in 'PHP' started by sheriek, Sep 6, 2010.

  1. #1
    Hello ,

    Kindly tell me how to create a user in php that make me able to show user as a separate in URL.

    For Example i have a registration form in php that create a new user1. So how can i create a separate URL for user1 like this www.abc.com/user1. While he/she access that page , will be able to see his/her profile.

    Thanks
     
    sheriek, Sep 6, 2010 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    What does a normal users url look like ?

    You use htaccess, but without a url we cant give you an example.
     
    MyVodaFone, Sep 6, 2010 IP
  3. sheriek

    sheriek Guest

    Messages:
    125
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What do you mean by users URL?? User can be any come to site and may register to mySite. So i want that user after creating his/her profile may access his/her own page.Like Tom registered to my site So he can visit his page on the following URL.

    www.localhost.com/Mysite/Tom

    Well I have registration page in the following URL www.localhost.com/Mysite/Register.php .

    Could you please elaborate how can i do this?? is it possible to do in php??
     
    sheriek, Sep 6, 2010 IP
  4. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #4
    So I'm guessing you haven't created a profile page yet, well do that first, call it profile.php for example, then you can use htaccess to make a different url appear in the browser address bar.
     
    MyVodaFone, Sep 6, 2010 IP
  5. sheriek

    sheriek Guest

    Messages:
    125
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yes i have done and named it Profile.php. Well Now kindly tell me How to use htaccess file for adding multiple users to this?? Or what to do?? Any example for this??
    Can i do this at my local server for testing purpose??
    Thanks for your kind reply.
     
    sheriek, Sep 6, 2010 IP
  6. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #6
    If you have mod_rewrite enabled.

    create a .htaccess and put the following into it.

    Options +FollowSymLinks
    
    RewriteEngine on
    
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteCond %{REQUEST_FILENAME} !-f
    
    RewriteRule (.[^/]*) /profile.php?username=$1 [NC,L]
    Code (markup):
    That should work, if you can already access a users url like this /profile.php?username=user1 // the word username here depends on you and how you already access users

    In the browser address bar for you it will look like http://localhost/user1
     
    MyVodaFone, Sep 6, 2010 IP