Create personal page for every user, PHP

后端 未结 4 2190
你的背包
你的背包 2021-01-03 14:25

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

相关标签:
4条回答
  • 2021-01-03 14:34

    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.

    0 讨论(0)
  • 2021-01-03 14:34

    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 讨论(0)
  • 2021-01-03 14:43

    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

    0 讨论(0)
  • 2021-01-03 14:56

    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

    0 讨论(0)
提交回复
热议问题