日期:2014-05-17 浏览次数:20545 次
<center>
<form action="addData.php" method="post" target="_blank" >
<p>账号:<input name="u_User" title="text" size="32" maxlength="32" /></p>
<p>密码:<input name="u_pwd" title="text" size="32" maxlength="32"/></p>
<input type="submit" value="注册" /><input type="reset" value="清空" />
</form></center>
<?php
/////////////////和mysql建立链接
$host = "localhost";$user="root";$pwd="";$DataBaseName="db_appdata";$db_name="appdata";
$con = mysql_connect($host,$user,$pwd);
if (!$con)
{
die('连接数据库失败: ' . mysql_error());
}
mysql_select_db($DataBaseName, $con); //选取数据库
////////////////////向表内插入数据
mysql_query("INSERT INTO $db_name (Name, pwd)
VALUES (.trim($_POST["u_user"]), .trim($_POST["u_pwd"])");
echo "添加成功";
//关闭连接
mysql_close($con);?>