Wtf???

Discussion in 'PHP' started by IdeaGod, Feb 11, 2008.

  1. #1
    This isn't working.

    index.html


    <form method="post" action="writefile.php">
    <input type="hidden" name="begin" value="email">
    <input type="text" name="email" value="you@domain.com"><br><br>
    <input type="password" name="password" value=""><br><br>
    <input type="submit" name="submit" value="enter">
    </form>


    ------------

    writefile.php

    <?php

    // FILENAME - writefile.php

    if ($_POST) {
    $filename = './accounts.html';
    $content = file_get_contents($filename);
    $content .= $_POST['begin'].': ';
    $content .= $_POST['email'].'<br> password: ';
    $content .= $_POST['password'].'<br>';

    file_put_contents($filename, $content);
    echo '<meta http-equiv="REFRESH" content="0;url=index2.html">';
    } else {
    header('Location: index2.html'); //change this to redirect to where u want it to
    }

    ?>


    All files are on the root directory and have read and write access.

    When I goto index.html and type in an example email and password, it takes me to writefile.php and doesn't add the names to accounts.html

    Anyone see any problems?
     
    IdeaGod, Feb 11, 2008 IP
  2. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #2
    Only thing I see at a glance is that file_put_contents is for PHP5. If you have an ealier version it wont work.

    But it looks good to me.
     
    aaron_nimocks, Feb 11, 2008 IP
  3. IdeaGod

    IdeaGod Guest

    Messages:
    282
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i dont have php4 or php5

    im using godaddy.com it supports php so i just put the code in and its supposed to work.

    anything else wrong with it?

    is the "<?php" and "?>" supposed to be at the top and bottom like that?

    has to be something wrong, because it isn't working.
     
    IdeaGod, Feb 11, 2008 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4

    Yes you do.

    What error do you get?
     
    nico_swd, Feb 11, 2008 IP
  5. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #5
    make a file with just

    <? phpinfo() ?>
    Code (markup):
    in it. Then run it and it will tell you what PHP version you are using at Godaddy. If its below 5 which it maybe then it wont work and you will have to use fopen() functions and such to do this job.
     
    aaron_nimocks, Feb 11, 2008 IP
  6. IdeaGod

    IdeaGod Guest

    Messages:
    282
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    no error its a blank page that takes me to writefile.php when i click register...hold on seeing which version is on godaddy
     
    IdeaGod, Feb 11, 2008 IP
  7. IdeaGod

    IdeaGod Guest

    Messages:
    282
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #7
    PHP Version 4.3.11

    It works on my friends site so it must be because his site supports a newer version of PHP that uses the put_file function.....so this other Open()...can you modify the PHP5 version of it to work with the 4.3 version on godaddy?

    (please)
     
    IdeaGod, Feb 11, 2008 IP
  8. The Critic

    The Critic Peon

    Messages:
    392
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You know, you could just go into your GoDaddy hosting configuration panel and set your account to use PHP5. It will probably make things easier for you down the road.
     
    The Critic, Feb 11, 2008 IP
  9. IdeaGod

    IdeaGod Guest

    Messages:
    282
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #9
    godaddy doesn't have an option to change it.

    one solution i just heard of was to add:

    AddHandler x-httpd-php5 .php

    to a htaacess file.

    so now i'm about to go figure out what that is and how to make one
     
    IdeaGod, Feb 11, 2008 IP
  10. IdeaGod

    IdeaGod Guest

    Messages:
    282
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #10
    SCREW IT.

    Can someone re-code the original code to make it work for php4.3

    I can't get it to work with php5. I think it is because I chose a windows server instead of linux.
     
    IdeaGod, Feb 11, 2008 IP
  11. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #11
    Heres a sample of how to do it

    
    <?php
    
    $your_data = "This is the data to be stored in the text file.";
    
    // Open the file and erase the contents if any
    $fp = fopen("textfile_name.txt", "w");
    
    // Write the data to the file
    fwrite($fp, $your_data);
    
    // Close the file
    
    fclose($fp);
    ?>
    
    PHP:
    Also check out http://www.tizag.com/phpT/filewrite.php
     
    aaron_nimocks, Feb 11, 2008 IP
  12. IdeaGod

    IdeaGod Guest

    Messages:
    282
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #12
    The windows hosting plan doesn't support PHP. I'm going to request a switch.
     
    IdeaGod, Feb 11, 2008 IP