$dbhost = "localhost"; //安装数据库是设定的主机名称
$dbuser = "root"; //数据库登录用户名
$dbpass = "root"; //数据库登录密码
$connect = mysql_connect($dbhost,$dbuser,$dbpass); //连接数据库
if ($connect)
{
echo "Link Successful ! <br>";
mysql_select_db("webdata",$connect); //选择要用的数据库
mysql_query("insert into guest values('$name','$sex', //执行sql语句
'$age','$addr')",$connect); //name,sex,age,addr是表单文本域名称。
}
else
{
echo "Link Failed !";
}
?>