php代码:
<?php
$name=$_POST["name"];
$pw= md5($_POST["pw"]);
$con=mysql_connect('localhost','root','123456') or die('链接数据库失败!');
mysql_select_db('baocun' ,$con);
$c="SELECT*FROM shuju WHERE name='$name'";
$z=mysql_query($c);
$row=mysql_fetch_row($z);
if($row!=0)
{
echo "用户存在";}
else{
$r="insert into shuju (name,password) values ('$name','$pw')";
mysql_query($r, $con);
echo "注册成功";
}
mysql_query("set name utf8");?>
html代码:
<form style="text-align:center" action="ppp.php" method="post">
<p>用户
<input name="name" type="text" size="20" />
</p>
<p>密码
<input name="pw" type="password" size="20" />
</p>
<input type="submit" value="注册" />
</form>