www.webdeveloper.com
Results 1 to 3 of 3

Thread: How do I display <input text> data

  1. #1
    Join Date
    Jul 2003
    Posts
    138

    How do I display <input text> data

    I need to input some text on a website page <input textarea> (or something like that) to a .txt file
    I then need to display this text on a different page when required..

    As I'm not php proficient - can anyone write me a bit of code or correct the codes below so it will do the above?

    Any help appreciated...

    This is what I got for the input part -

    <form action='?#bottom' method=post>
    <input type='text' name='message' size='120'>
    <input type='submit' value='Submit'>
    </form>
    <?
    if(isset($_POST['message']) && isset($_POST['user'])){
    $x = fopen("newspage.txt", 'a');
    if(get_magic_quotes_gpc){
    $_POST['message'] = stripslashes($_POST['message']);
    };
    fwrite ($x, htmlspecialchars(str_replace("\n", "", $_POST['message']))."\n");
    fclose($x);
    };
    ?>


    I have this piece of code for the display part but cant test it until I get the input working, and I can't do it (I've tried) .txt file is called 'newspage.txt'

    <?
    if(file_exists("newspage.txt")){
    echo "<div style='display: block; text-align: left; height: 80%; width: 60%; overflow: scroll; background-color: #ffffff;'><span class='s12 c6'>";
    $lines = file("newspage.txt");
    $i = 0;
    foreach ($lines as $line) {
    if($i == 0){
    echo "<span class='s10 c1 f5'>$line: \n";
    }else{
    echo "$line<br>\n";
    };
    $i = !$i;
    };
    echo "<a name='bottom'></a></div>";
    };
    ?>


    Thanx...

  2. #2
    Join Date
    Jul 2005
    Location
    USA
    Posts
    912
    As I'm not php proficient - can anyone write me a bit of code or correct the codes below so it will do the above?
    At least you're honest but since you outright asked for someone to write you code, nobody probably will.

  3. #3
    Join Date
    Jul 2003
    Posts
    138
    Thanx that was really useful - thought you guys were on here to help..?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles