微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Head First PHP&MySQl第一章代码

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>
    Yes <input id="fangspotted" name="fangspotted" type="radio" value="yes" />
    No <input id="fangspotted" name="fangspotted" type="radio" value="no" /><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['firstname'] . ' ' . $_POST['lastname'];
    $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";
    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>

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐