HTML:php
<!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:css
form label { display: inline-block; width: 225px; font-weight: bold; }
PHP:html
<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>