Can you pls help me in this problem

Discussion in 'PHP' started by nawabsheriff, Jan 21, 2009.

  1. #1
    hi

    i am a beginner of php

    i just want to know the code or procedure to write a data in file automatically when submit button is clicked..

    for example.

    if i am getting a data from the user like name,age etc....after finishing the form ,if user clicks the submit button ,it should be automatically store in word pad or note pad...

    pls help me in this problem..
     
    nawabsheriff, Jan 21, 2009 IP
  2. fatedesign

    fatedesign Peon

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Have an html form set up like...

    <html><head></head><body><form method="POST" action="action.php">
    <p><input type="text" name="name" /></p>
    <p><input type="text" name="age" /></p>
    <p><input type="submit" value="Submit" /></p>
    </form>
    </body></html>

    Then have a PHP file to process it like so...

    <?php
    $content = $_POST['name']."\n".$_POST['age']."\n \n";
    $fh1 = fopen("storeInfo.txt", 'w') or die("Error, can't open file");
    fwrite($fh1, $content);
    fclose($fh1);
    ?>
     
    fatedesign, Jan 21, 2009 IP
  3. red_mamba

    red_mamba Peon

    Messages:
    63
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    look file_put_contents on php.net for help
     
    red_mamba, Jan 22, 2009 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    fopen, fwrite, fclose, etc.. will do the trick
     
    bartolay13, Jan 22, 2009 IP
  5. nawabsheriff

    nawabsheriff Banned

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you.....

    its working
     
    nawabsheriff, Jan 22, 2009 IP