Create personal page for every user, PHP

隐身守侯 提交于 2019-11-29 23:30:04

问题


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 this when a user registers on my web page.


回答1:


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




回答2:


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




回答3:


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.




回答4:


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



来源:https://stackoverflow.com/questions/3721390/create-personal-page-for-every-user-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!