The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End html form that will post to a .txt file

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #37871

    Can somebody please help me? I can’t figure how to make a html form post to a .txt file i know it takes a php script I just don’t know that much about php. All I need is first name, last name, and date. thanks.


    I don’t know, i’ve never used json before. let me tell you what i’m doing. One of my customers sites has baby registries on it they want their employees to be able to change them without having to edit the html code manually. So I wanted to create a html input form that will post the name and date somewhere so another script would read the names and post them on a page. I already have the one that reads a .txt file but I may have to change it now.


    I’m sorry but I pretty new to development and I don’t know how to do that either.


    I’m willing but I’m in high school so I might not be able to do everything right away. Also I’m with media temple so I’m pretty sure I can make a database pretty easy if your willing to help me everything.


    This is a script I put together a while back. It puts stuff into the format ->

    Title, Comment, Author, Date

    function CleanStr($str){
    $str = trim($str); //Remove leading and trailing whitespace
    if (get_magic_quotes_gpc()) { //magic quotes is deleted (?)
    $str = stripslashes($str);

    $str = htmlspecialchars($str);//remove html special chars
    $str = str_replace("&", "&", $str);//remove ampersands

    return str_replace(",", ",", $str);//remove commas and change to special chars # THIS IS VITAL!

    if($_SERVER["REQUEST_METHOD"] != "POST") error("Error: No POST.",$dest);

    // Check the contents of the form
    if(!$name||ereg("^[ |@|]*$",$name)) $name=""; // If field is empty or that unknown Jap character found...
    if(!$com||ereg("^[ |@|t]*$",$com)) $com=""; // and or a tab character...
    if(!$sub||ereg("^[ |@|]*$",$author)) $author=""; // make field empty.
    if(!$com) die("Please write something.");

    $name = CleanStr($name);
    $com = CleanStr($com);
    $author = CleanStr($author);

    $com = str_replace( "rn", "n", $com);
    $com = str_replace( "r", "n", $com);
    // Continuous lines
    $com = ereg_replace("n((!@| )*n){3,}","n",$com);
    $com = nl2br($com); //br is substituted before newline char

    $com = str_replace("n", "", $com); //delete n from a string.

    if($pass == "thisisthepassword") { // See that the password is correct

    $filename = 'logfile.txt';

    //set what will be written
    $content_r = $name.",".$com.",".$author.",".date('l jS of F Y h:i:s A')."n"; //this will write in the values on a new line separated by commas

    $file = fopen($filename,"a") or die ("Error opening file in write mode!");
    fclose($file) or die ("Error closing file!");

    } //closing of If statement for the password.

    And this is the html form to go with it:
    (excuse the table, but it makes it all neat and tidy)

    Everything Good?

    I hope this helps and makes a bit more sense, it works differently to the above scripts but variety in learning and techniques is always good.


    I said I was willing but I don’t think I could figure this out between school and work. Is there another way I could go about this just as a temporary. This is the test page you will have to create a login if you want to see what I have already done. Please don’t give up on me I’ve bee trying to figure this out forever.

    If you dont want a create a login it’s
    password: royalgmc
    and then go to “A sample ‘members-only’ page”


    I had an idea, what about if I used a wordpress blog for posting the registries since I don’t have the time for the other stuff. It would be like each post was a registry and you could post and delete them whenever you wanted. Plus it would be easier on my customers employees. What do you think? Good or bad idea

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Back End’ is closed to new topics and replies.