Results 1 to 4 of 4

Thread: PHP form thing

  1. #1
    Join Date
    Feb 2007
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP form thing

    I think you may need to point me to a free php download for this.

    I need a shoutbox sort of thing (but not a shout box)

    so a user fills out a form, with the fields:

    field1
    field2
    field3
    field4

    Then it addds to the top of a page, above all the previous ones in the form of for example.

    Field1 said field2 and then field3...

    so it forms part like that ^

    Also if possible i want it to be easy for me to add fields.

    I made one but it is rubbish and allways writes over the previous form submition

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    If it writes over the previous submission, you may want to add a file_get_contents() to the added data.
    If you use a handle such as w+, or w, you need to do this. Example:
    Code:
    $data = file_get_contents("includes/mydata.txt").$form1.$form2.$etc;
    We'll need to see the code to be more accurate though.
    - Mike

  3. #3
    Join Date
    Feb 2007
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes it does overwrite and i do use that to get the messages, im bad at PHP and if you want to see it its really messy :S

  4. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    We do need to see it to help you, regardless of how bad it's written.
    Here's an example though:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>write content</title>
    </head>
    <body>
    <?php
    $s = $_GET["send"];
    $file = "path/to/myfile.txt";
    $pfile = file_get_contents($file);
    if (isset($s)) {
    	$handle = fopen($file,"w+");
    	$data = $pfile."\n<hr>"."<b>".$_POST["name"]."</b>"."<br>".$_POST["message"];
    	fwrite($handle,$data);
    	fclose($handle);
    	}
    ?>
    <?php
    echo $pfile;
    ?>
    <hr>
    <form method="post" action="?send">
    	Name:
    	<br><input type="text" name="name">
    	<br>Message:
    	<br><textarea name="message" rows="9" cols="46"></textarea>
    	<br><input type="submit">
    </form>
    </body>
    </html>
    - Mike

Bookmarks

Posting Permissions

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