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

Head First PHP&MySQl第二章代码

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'];

    //DatabaseAddress:数据库地址;username:用户名;command:口令;DatabaseName:数据库名字;
    $dbc = MysqLi_connect('DatabaseAddress','username','command','DatabaseName')
        or die('连接MysqL错误.');

    //参数与数据库的表单的列有关
    $query = "TNSERT INTO TableName (name, when_it_happened, how_long, ".
        "how_many, alien_description, what_they_did, fang_spotted, other, email)".
        "VALUES (' $name, $when_it_happened, $how_long, $how_many, ".
        "$alien_description, $what_they_did, $fang_spotted, $other, $email)";
    $result = MysqLi_query($dbc, $query)
        or die('查询数据库错误。');
    MysqLi_close($dbc);

    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 举报,一经查实,本站将立刻删除。

相关推荐