Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2009
    Posts
    656
    Tokens
    0

    Default Generate random filename and then get the filename?

    Okay so I want to have it so someone puts something into a form on another page and when they click the button it creates a random number generated textfile AND THEN writes to that textfile, I've got the random number textfile working okay but how do I then write to the new file I just created without knowing what the filename is?

    Basically here's how it goes..

    *Name into form*
    *Press the button*
    *create random named textfile*
    *write the name that the person entered into the form into the textfile*

    But I do not know how to get the textfile name because its random

    Help appreciated thankzz
    Last edited by Stefy09; 17-06-2009 at 10:12 PM.

  2. #2
    Join Date
    May 2009
    Posts
    14
    Tokens
    0

    Default

    Google fwrite, that's all I need to say.

  3. #3
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Just write the data to that single file?

    Once you've ran it through a random text generator, have php write to that file using fwrite and then save it?
    Back for a while.

  4. #4
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    Not 100% sure if this works (haven't tested) and it's a long time since I've done anything like this, but it's worth a shot anyway:

    PHP Code:
    <?php

    if($_POST['form_name']) {

        
    $name $_POST['name'];
        
    $rand random(1,10000);
        
        while(
    file_exists($rand '.txt') {
            
    $rand random(1,10000);
        }
        
        
    $full_path $rand '.txt';
        
        
    $file_op fopen($full_path'w');
        
        
    fwrite($file_op$name);
        
        
    fclose($file_op);

    }

    ?>

  5. #5
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    PHP5 has a neat function.. file_put_contents.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •