#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    I am writing a web page whereby users can sign up at my site and will be given space for their personal home page.

    How then, do I use PHP to create a new file for each new user (eg user.html)? The commands I looked through on the on-line manual do not seem to have this function (create new file function). Does PHP have a function of this sort anyway?
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    $fp=fopen("path/to/file/user.html","w");
    fwrite($fp,"data you want in the file");
    fclose($fp);

    Check out all the related commands in the manual under the "filesystem" section.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Norcross, GA
    Posts
    458
    Rep Power
    15
    When I used the following script:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?php

    $fp=fopen("test.txt","w");
    fwrite($fp,"This is a test");
    fclose($fp);

    ?>
    [/code]

    I received these errors:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>

    Warning: fopen("test.txt","w") - Permission denied in /home/httpd/html/techman/mss/admin/testwrite.php3 on line 3

    Warning: Unable to find file identifier 0 in /home/httpd/html/techman/mss/admin/testwrite.php3 on line 4

    Warning: Unable to find file identifier 0 in /home/httpd/html/techman/mss/admin/testwrite.php3 on line 5
    [/code]

    Any ideas on what the problem is?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    63
    Rep Power
    15
    You need to change the permissions for /home/httpd/html/techman/mss/admin
    to include write access.

    [This message has been edited by chris22 (edited September 13, 2000).]
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    11
    Rep Power
    0
    -

    [This message has been edited by Jasper (edited September 14, 2000).]
  10. #6
  11. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,645
    Rep Power
    4492
    A good way to do this is to have all of the files already created, then just create the user directory, and copy all of the files over. That way you're not actually writing entire files each time someone signs up. If you're adding a lot of personalized stuff to each page, then it might be easier to write it each time, though.

    my $0.02

    ---John Holmes...

Similar Threads

  1. Replies: 3
    Last Post: February 17th, 2004, 10:08 AM
  2. Replies: 2
    Last Post: February 6th, 2004, 07:25 AM
  3. PHP file upload script trouble
    By casbboy in forum PHP Development
    Replies: 9
    Last Post: February 5th, 2004, 07:42 PM
  4. Replies: 3
    Last Post: February 3rd, 2004, 02:49 PM
  5. Simple find and replace word search for a text file with php?
    By rabid lemming in forum PHP Development
    Replies: 4
    Last Post: February 1st, 2004, 09:37 PM

IMN logo majestic logo threadwatch logo seochat tools logo