数据库
首页 > 数据库> > Head First PHP&MySQl第一章代码

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>

 

标签:Head,Fang,绑架,邮箱地址,外星人,echo,how,MySQl,PHP
来源: https://www.cnblogs.com/lyd575/p/11105918.html