Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

youlichika

macrumors member
Original poster
Aug 27, 2010
35
0
Hello everybody, I have a PHP personal space systems. It allows user registration, then get a personal space. But all it points the URL address to www.mysite.com. What php documents should I modify, make it like FACEBOOK: each user has his own URL address, convenient to share with his friends. (www.mysite.com/ + personal extension name) Thanks.
 
With php you would do something like a mysite.com?name=user1

Then call this from the php as i have shown below. This can get far more elaborate and you can use htaccess to rewrite mysite.com?name=user1 to mysite.com/user1
PHP:
<?php
switch ($_REQUEST["name") {
    case "user1":
        echo "This is user 1's home page.";
        break;
    case "user2":
        echo "This is user 2's home page.";
        break;
    case "user3":
        echo "This is user 3's home page.";
        break;
}
 
babyjenniferLB,T=thanks.
I have checked my php system. it has already had a .htaccess.
I open it, it wrote somthing in it.

HTML:
AddCharset utf-8 .php
AddDefaultCharset utf-8

AddType image/ico ico
AddType image/x-icon ico

DirectoryIndex index.php
Options -Indexes

<Files ~ "\.(ini)$">
deny from all 
</Files>

Then I add your code below it, it did not work.
I am a newer for .htaccess.
So would you like to help me more?
have a nice day.
 
babyjenniferLB,T=thanks.
I have checked my php system. it has already had a .htaccess.
I open it, it wrote somthing in it.

HTML:
AddCharset utf-8 .php
AddDefaultCharset utf-8

AddType image/ico ico
AddType image/x-icon ico

DirectoryIndex index.php
Options -Indexes

<Files ~ "\.(ini)$">
deny from all 
</Files>

Then I add your code below it, it did not work.
I am a newer for .htaccess.
So would you like to help me more?
have a nice day.

My code is for php not for htaccess. The htaccess code would be a little less complex. Start firstly by getting it right using the ?= method.
 
When the person logs in you should be keeping track of who they are (using cookies or sessions) and you just redirect them as necessary. How to do this effectively will depend on the login system you're using.
 
Thanks a lot. I'll try to add the code in my index.php, but it not work.
The code is:

HTML:
session_start();
if(empty($_SESSION['user_id'])){    
header("location: myspace.php");
}
else header("location: myspace.php?id=".$_SESSION['user_id']);

And the login.php code like:
HTML:
    function run() {
        $user_id = isset($_REQUEST['user_id']) ? getSafeStr($_REQUEST['user_id']) : null;
...// $email, $password like $user_id

        switch($this->act) {
            case "start_anonymus":
...//database query
                $_SESSION['user_id'] = $res_id;
                return array("status" => "start_result", 
                             "user" => array("id" => $res_id, 
                                             "email" => "", 
                                             "password" => ""));
                break;
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.