21,887
社区成员
发帖
与我相关
我的任务
分享
$conn =mysql_connect("localhost", "root", "") or die("数据库链接错误");
$result=mysql_select_db("info", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;
if($result){
echo "建立完成";
}else{
echo "建立错误".mysql_error();
}
<?php
/*
* Created on 2011-6-9
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include("conn.php");
if($_POST['submit']){
$sql="insert into test (id,user,password) values('','$_POST[user_name]','$_POST[PW]')";
mysql_query($sql);
echo "成功";
}
?>
<form action="add_user.php" method="post">
用户:<input type="text" name="user_name" /><br/>
密码:<input type="text" name="PW" /><br/>
<input type="submit" name="submit" value="登陆"/>
</form>
error_reporting(E_ALL);
$sql="insert into test (id,user,password) values('','$_POST[user_name]','$_POST[PW]')";
//↓
$sql="insert into test (id,user,password) values('','$_POST[\"user_name\"]','$_POST[\"PW\"]')";