简明现代魔法 -> PHP服务器脚本 -> 不用mysqli类的数据库写入方法
不用mysqli类的数据库写入方法
2009-08-31
程序代码
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
$name = $_POST['name'];
$companyname = $_POST['companyname'];
$position = $_POST['position'];
$address = $_POST['address'];
$postcode = $_POST['postcode'];
$tel = $_POST['tel'];
$fax = $_POST['fax'];
$email = $_POST['email'];
$website = $_POST['website'];
//连接数据库
$myconn=mysql_connect("localhost","root","");
mysql_select_db("info",$myconn);
//将用户填写信息添加到数据库
$strSql="insert into premax2009(name,companyname,position,address,postcode,tel,fax,email,website)
values('$name','$companyname','$position','$address','$postcode','$tel','$fax','$email','$website')";
$result=mysql_query($strSql,$myconn) or die(mysql_error());
//关闭对数据库的连接
mysql_close($myconn);
echo "<br><br><br><center>注册成功<br><br><br><br><a href=\"premax_Query.php\">察看注册信息</a></center>";
?>
</body>
</html>

