如何将表单输入发送到文本文件和/或数据库?

So I have made a "Coming Soon" page and I have a form to sign up for a newsletter but I cant seem to get the coding right.

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Coming Soon to a Browser Near You</title>        
        <link rel="stylesheet" type="text/css" href="style.css" />

        <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js'></script>
        <script type='text/javascript' src='javascripts/jquery.tipsy.js'></script>
        <script type='text/javascript'>
        $(function() {
            $('#tipsy').tipsy({fade: true, gravity: 's'});
        });
        </script>
        <!--[if IE]>
        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

    </head>
    <body>
        <div class="wrapper">
<!--            <img src="images/logo.png" alt="YourLogo" title="YourLogo"/>
-->         <h1>SirAethon</h1>
            <div class="hr"></div>
            <h3>Coming Soon to a Browser Near You</h3>
            <p>Unfortunately, we’re not quite ready yet. <strong> But, you can see our progress below:</strong></p>

            <section class="progress">
                <div class="progress-bar-container" id="tipsy" title="8% Complete"> <!-- Edit this title for the tooltip pop up -->
                    <article class="progress-bar" style="width:8%"  ></article> <!-- Edit the width percentage value to indicate progress -->
                </div>
                <article class="txt-launch-day-hat"></article>
            </section>

            <div class="hr"></div>
            <section class="mailing-list">
                <h2>Want to be the first to know when we're ready?</h2>
                <form>
                    <input type="text" value="your@email.com" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;">
                    <input type="submit" value="Subscribe"> 
                </form>
            </section><div class="clear"></div>
            <div class="hr"></div>

            <p class="credit">Designed by <a href="http://siraethon.com">SirAethon</a></p>
        </div>
    </body>
</html>

That is my index.html page. I want the form section to be able to take an email and confirm that it is an actual email then put that email into a text file so that I can come along later and take the emails so I can send a mass email at once.

        <section class="mailing-list">
            <h2>Want to be the first to know when we're ready?</h2>
            <form>
                <input type="text" value="your@email.com" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;">
                <input type="submit" value="Subscribe"> 
            </form>
        </section>

Above is the mailing list section along with the form.

(Any help is highly appreciated! Thank you in advance!)

EDIT1: So I have gotten it to work but now it says "13 bytes written to file" once you click the subscribe button how do I fix it from saying this and make it say something else like thank you for subscribing?

I used these coding:

Form:

        <form action="php/signup.php" method="POST">
            <input name="field1" type="text" value="your@email.com" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;">
            <input type="submit" name="submit" value="Save Data">
        </form>

signup.php:

<?phppublic_html/the-fam.com/php/signup.php
if(isset($_POST['field1'])) {
    $data = $_POST['field1'];
    $ret = file_put_contents('emails.txt', $data, FILE_APPEND | LOCK_EX);
    if($ret === false) {
        die('There was an error writing this file');
    }
    else {
        echo "$ret bytes written to file";
    }
}
else {
   die('no post data to process');
}

EDIT2: So i tried to fix it saying bytes written to file and now its not displaying anything nor is it writing to file: "$ret bytes written to file" I removed that part then replaced it and nothing is happening but I replaced it back and still nothing is happening

If you want to look at the site your self it is http://the-fam.com

Your form has no action or method, therefore it does nothing. You probably want method="post" and action="some_script.php", where the some_script.php file will handle doing whatever you want with the data (validation, save to file, save to database, etc.). You will also want name="email" or something along those lines as an attribute on your text input. That way you can access it via $_POST['email']

This should get you started, you will need to be running the site on a server such as Wamp. The page should submit to itself to get you going. Once it submits it will check that the email is valid and write it to a file.

<?php 
if( isset( $_POST ) )
{
  $email = test_input($_POST["email"]);
  if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    $emailErr = "Invalid email format";
  }
  else
  {
    $myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
    $txt = "$email
";
    fwrite($myfile, $txt);
    fclose($myfile);
  }    
}
?>

<form method="post" action="" >
  <input type="text" value="your@email.com" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;">
  <input type="submit" value="Subscribe"> 
</form>