html:

<!doctype html>
<html lang="zh-cn">
<head>
  <meta charset="utf-8">
  <title>外星人绑架了我--报道一起绑架</title>
  <link rel="stylesheet" href="style.css" />
</head>
<body>
  <h2>外星人绑架了我--报道一起绑架</h2>

  <p>分享你的关于被外星人绑架的故事:</p>
  <form method="post" action="report.php">
    <label for="name">名字:</label>
    <input type="text" id="tname" name="name" /><br />

    <label for="email">邮箱地址:</label>
    <input type="text" id="email" name="email" /><br />

    <label for="whenithappened">发生的时间:</label>
    <input type="text" id="whenithappened" name="whenithappened" /><br />

    <label for="howlong">你消失了多久:</label>
    <input type="text" id="howlong" name="howlong" /><br />

    <label for="howmany">你看见多少多少外星人:</label>
    <input type="text" id="howmany" name="howmany" /><br />

    <label for="aliendescription">描述一下它们:</label>
    <input type="text" id="aliendescription" name="aliendescription" size="32" /><br />

    <label for="whattheydid">他们对你做了什么:</label>
    <input type="text" id="whattheydid" name="whattheydid" size="32" /><br />

    <label for="fangspotted">你看见过我的狗fang吗?</label>
    见过 <input id="fangspotted" name="fangspotted" type="radio" value="见过" />
    没有 <input id="fangspotted" name="fangspotted" type="radio" value="没有" /><br />

    <img src="fang.jpg" width="100" height="175"
      alt="my abducted dog fang." /><br />

    <label for="other">如果您还有其他的要说可以在这里写下:</label>
    <textarea id="other" name="other"></textarea><br />


    <input type="submit" value="提交" name="submit" />
  </form>
</body>
</html>

 

css:

form label {
  display: inline-block;
  width: 225px;
  font-weight: bold;
}

php:

<html>
<head>
    <title>外星人绑架了我--报道一起绑架</title>
</head>

<body>
    <h2>外星人绑架了我--报道一起绑架</h2>

    <?php
    $name = $_post['name'];
    $when_it_happened = $_post['whenithappened'];
    $how_long = $_post['howlong'];
    $how_many = $_post['howmany'];
    $alien_description = $_post['aliendescription'];
    $what_they_did = $_post['whattheydid'];
    $fang_spotted = $_post['fangspotted'];
    $email = $_post['email'];
    $other = $_post['other'];

    $to = '**********@**.com';
    $subject = '外星人绑架了我--报道一起绑架';
    $msg = "$name 被绑架了在 $when_it_happened 并且持续了 $how_long.\n" .
        "外星人的数量: $how_many\n" .
        "外星人的外貌: $alien_description\n" .
        "它们做了什么: $what_they_did\n" .
        "fang是否被看见: $fang_spotted\n" .
        "其他内容: $other";
  //需要安装sendmail才可以使用mail()函数 mail($to, $subject, $msg, 'from:' . $email); echo '非常感谢你提交的表单.<br/>'; echo '你在什么时候被绑架的?'.$when_it_happened.'<br/>'; echo '你被带走了多长时间? '.$how_long.'<br/>'; echo '外星人的数量是多少? '.$how_many.'<br/>'; echo '外星人的外貌是什么样? '.$alien_description.'<br/>'; echo '外星人做了什么? '.$what_they_did.'<br/>'; echo 'fang在不在那里? '.$fang_spotted.'<br/>'; echo '其它内容: '.$other.'<br/>'; echo '你的邮箱地址是: '.$email.'<br/>'; ?> </body> </html>