开发者

Create personal page for every user, PHP

What I want to do is to create a web page for every user when they signup on my page.

For Example: www.someweb.com/username, and this will be their webpage.

I know that this can be done easily with mkdir() and other related functions, but the problem is that my root folder is not chmod 777 and I don't want to chmod 777 this root folder because of security reasons.

What is the best way to do开发者_如何学C this when a user registers on my web page.


You don't make physical directories for each user, you use URL rewriting. Take a look at this source:

HTML Source : HTML Tutorials, URL Rewriting


Most likely you don't need to create these directories in real.
Just make it virtual.
Pass a username using query string, like this:

www.someweb.com/index.php?user=username

And personalize this page according to particular username. After that you can do some rewrite magic and make a page address like this www.someweb.com/username but all pages will remain virtual


Use mod_rewrite to make a request to /username actually be ?user=username. You can then get the appropriate user's data and display it in a template.


if you want to create personal page for each user after signup

->when a new user do the signup at ur site then create a new directory with the name of username at the location of user folder like /user/username/

create a file under this directory with name of index by using create file function /user/username/index write the following code using read/write operations if ur using php

<?php
$myfile = fopen("\user\$_SESSION["username"].php", "w") or die("Unable to create file!");
$str = "<?php 
        \$p_username = ".$_SESSION['username']."; 
        include('../user-profile.php');
    ?>";
fwrite($myfile, $str);
fclose($myfile);
?>

this user-profile will have the functionality to retrieve the user info from the database with the help of variable $p_username. in this way an user can also visit the profile of other user

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜