时间:2021-07-01 10:21:17 帮助过:19人阅读
<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>
Head First PHP&MySQl第二章代码
标签:用户名 数据库名 地址 nec -- 有关 query 用户 color