http://www.tssn.net

PHP教程一个表单链接数据库录入信息

<html>
<head>
<title>Aliens Abducted Me-Report an Abduction</title>
</head>
<body>
<h2>Aliens Abducted Me-Report an Abduction</h2>
<?php
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
 
$when_it_happened = $_POST['whenithappened'];
$how_long = $_POST['howlong'];
$how_many = $_POST['howmany'];
$what_they_did = $_POST['whattheydid'];
 
$alien_description = $_POST['aliendescription'];
$fang_spotted = $_POST['fangspotted'];
$email = $_POST['email'];
$other = $_POST['other'];
 
$dbc = mysqli_connect('127.0.0.1','root','root','aliens')
or die('error connecting to mysql server');
 
$query = "insert into aliens_abduction (first_name,last_name,when_it_happened,how_long,".
"how_many,alien_description,what_they_did,fang_spotted,other,email)" .
"VALUES ('$first_name','$last_name','$when_it_happened','$how_long','$how_many',".
"'$alien_description','$what_they_did','$fang_spotted','$other','$email')";
 
$result = mysqli_query($dbc,$query)
or die('error querying database.');
mysqli_close($dbc);
 
 
echo 'Thanks for submitting the form. <br/>';
echo 'You were abducted'. $when_it_happened;
echo 'and were gone for'. $how_long . '<br />';
echo 'number of alience'. $how_many . '<br />';
echo 'the alien did this'. $what_they_did . '<br />';
echo 'describe them:'. $alien_description . '<br />';
echo 'was fang there?'. $fang_spotted . '<br />';
echo 'Other comments'. $other . '<br />';
echo 'You email address is '. $email;
?>
 
 
 
 
 
 
 
 
 
 
 
 
</body>
</html>

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。