<?php
header("content-type:text/html;charset=utf-8");
/* $mysql_username="localhost"; // 连接数据库用户名
$mysql_password=""; // 连接数据库密码*/
$mysql_database="test"; // 数据库的名字
// 连接到数据库
$conn = mysql_connect(‘localhost‘,‘root‘,‘‘) or die("MYSQL_connect:".mysql_errno());
mysql_select_db($mysql_database);
$name=$_POST[‘name‘];
$age=$_POST[‘age‘];
$sql = "INSERT INTO `test2` VALUES (‘$name‘,‘$age‘)";
$query = mysql_query($sql);
if($query){
echo ‘1‘;
}else{
echo ‘注册失败!‘;
}
?>
<!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>
<form id="form1" method="post" action="1.php">
<p>
姓名:
<input type="text" name="name"/>
</p>
<p >
年龄:
<input type="text" name="age"/>
</p>
<input type="submit" value="提交"/>
</form>
<div id="request-process-patent"></div>
</body>
</html>
原文地址:http://warmdoll.blog.51cto.com/10881334/1761839