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 7 of 7

Thread: Basic problem

  1. #1
    Join Date
    Dec 2007
    Posts
    2,807
    Tokens
    0

    Latest Awards:

    Default Basic problem

    <?php
    $title = $_POST["title"];
    $content = $_POST["content"];

    if(is_dir($title)) {
    echo 'Already exists.';
    } else {
    mkdir($title);
    $makeTextFile = fopen("$title/$title.txt" , "w");
    $writeTextFile = fwrite($makeTextFile, $content);
    fclose($makeTextFile);
    echo 'All done';
    }
    ?>
    What (if anything) is wrong with this? It may be the app thats sending to it thats wrong but Im not 100% sure.

  2. #2
    Join Date
    May 2008
    Posts
    605
    Tokens
    0

    Default

    Quote Originally Posted by FlyDuo View Post
    What (if anything) is wrong with this? It may be the app thats sending to it thats wrong but Im not 100% sure.
    Are you getting any errors?

  3. #3
    Join Date
    Dec 2007
    Posts
    2,807
    Tokens
    0

    Latest Awards:

    Default

    It creates the folder and text file inside it like it should but it doesnt write the content in the text file.

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

    Latest Awards:

    Default

    Well first off the code is awful, second off.. I'm pretty sure it's not posting the data, and is probably using a GET request.

    How is your application sending the data? Is it through the URL? blah.php?type=test&name=blah

  5. #5
    Join Date
    Dec 2007
    Posts
    2,807
    Tokens
    0

    Latest Awards:

    Default

    I'm sending it via POST from an xcode app like this:
    "NSString *myRequestString = @"title=random title";"

    If you dont mind me asking. How do you think I could sort out the PHP code?
    Read your messages too
    Last edited by MrPinkPanther; 03-04-2009 at 08:13 PM.

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

    Latest Awards:

    Default

    Quote Originally Posted by FlyDuo View Post
    I'm sending it via POST from an xcode app like this:
    "NSString *myRequestString = @"title=random title";"

    If you dont mind me asking. How do you think I could sort out the PHP code?
    Read your messages too
    I read the message and replied to your thread.

    PHP Code:
    <?php
    /* Gets the data from the request. */
    $title $_POST["title"];
    $content $_POST["content"];

    /* Checks for empty data. */
    if(empty($title) || empty($content)) {
        exit(
    "You have empty fields.");
    }

    /* Checks to see if the folder exists. */
    if(file_exists($title)) {
        exit(
    "Folder already exists.");
    }

    mkdir($title); // makes directory.

    $file file_put_contents("{$title}/{$title}.txt"$content); // puts the content in the file, saves it.
    echo "All done.";
    ?>

  7. #7
    Join Date
    Dec 2007
    Posts
    2,807
    Tokens
    0

    Latest Awards:

    Default

    You are a genious and I love you Ha ha.

Posting Permissions

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