<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<?php
if(isset($_POST['tj']))//若点击了提交
{
$conn=mysql_connect("localhost","username","password");
mysql_select_db("eastses",$conn);
mysql_query("set names utf8",$conn);
date_default_timezone_set("asia/chongqing");
$sql = "INSERT INTO `eastses`.`classmate` (`id`, `name`, `nickname`, `birthday`, `home`, `blood`, `qq`, `weibo`, `email`, `phone`, `hobby`, `food`, `sentence`, `gift`, `lover`, `keenon`, `unforgettable`, `wanttobecome`, `ideal`, `other`) VALUES ('".$_POST['id']."', '".$_POST['name']."', '".$_POST['nickname']."', '".$_POST['birthday']."', '".$_POST['home']."', '".$_POST['blood']."', '".$_POST['qq']."', '".$_POST['weibo']."', '".$_POST['email']."', '".$_POST['phone']."', '".$_POST['hobby']."', '".$_POST['food']."', '".$_POST['sentence']."', '".$_POST['gift']."', '".$_POST['lover']."', '".$_POST['keenon']."', '".$_POST['unforgettable']."', '".$_POST['wanttobecome']."', '".$_POST['ideal']."', '".$_POST['other']."');";
if( mysql_query($sql,$conn)>0)
{
echo "<script>alert('数据添加成功!');</script>";}
$res=mysql_query("select * from classmate",$conn);
$i=0;
while($arr=mysql_fetch_array($res))
{
$i++;
echo "第".$i."条数据:";
print_r($arr);
echo "<br><br>";
}
}
?>
<form action="" method="post" name="form1" >
<table width="300" border="0">
<tr>
<td>id:</td>
<td><input type="text" name="id" id="id" /></td>
</tr>
<tr>
<td>name:</td>
<td><input type="text" name="name" id="name" /></td>
</tr>
<tr>
<td>nickname:</td>
<td><input type="text" name="nickname" id="nickname" /></td>
</tr>
<tr>
<td>birthday</td>
<td><input type="text" name="birthday" id="birthday" /></td>
</tr>
<tr>
<td>home</td>
<td><input type="text" name="home" id="home" /></td>
</tr>
<tr>
<td>blood</td>
<td><input type="text" name="blood" id="blood" /></td>
</tr>
<tr>
<td>qq</td>
<td><input type="text" name="qq" id="qq" /></td>
</tr>
<tr>
<td>weibo</td>
<td><input type="text" name="weibo" id="weibo" /></td>
</tr>
<tr>
<td>email</td>
<td><input type="text" name="email" id="email" /></td>
</tr>
<tr>
<td>phone</td>
<td><input type="text" name="phone" id="phone" /></td>
</tr>
<tr>
<td>hobby</td>
<td><input type="text" name="hobby" id="hobby" /></td>
</tr>
<tr>
<td>food</td>
<td><input type="text" name="food" id="food" /></td>
</tr>
<tr>
<td>sentence</td>
<td><input type="text" name="sentence" id="sentence" /></td>
</tr>
<tr>
<td>gift</td>
<td><input type="text" name="gift" id="gift" /></td>
</tr>
<tr>
<td>lover</td>
<td><input type="text" name="lover" id="lover" /></td>
</tr>
<tr>
<td>keenon</td>
<td><input type="text" name="keenon" id="keenon" /></td>
</tr>
<tr>
<td>unforgettable</td>
<td><input type="text" name="unforgettable" id="unforgettable" /></td>
</tr>
<tr>
<td>wanttobecome</td>
<td><input type="text" name="wanttobecome" id="wanttobecome" /></td>
</tr>
<tr>
<td>ideal</td>
<td><input type="text" name="ideal" id="ideal" /></td>
</tr>
<tr>
<td>other</td>
<td><input type="text" name="other" id="other" /></td>
</tr>
<tr>
<td><input type="submit" name="tj" id="tj" value="提交" /></td>
<td></td>
</tr>
</table>
</form>
</body>
</html>本回答被提问者采纳