21,891
社区成员
发帖
与我相关
我的任务
分享
//这个是注册页面register.php
if(!isset($error))
{
$conn=mysql_connect("127.0.0.1","root","");
$qurry= "insert into ut(name,pwd,sex)values('$name','$pwd','$select')";
$result = mysql_db_query("test",$qurry);
echo "注册成功";
header("Location:on_ok.php?names=$name&pwd=$pwd");
}
else
{
echo "注册失败";
header("Location:on_error.php?error=$error");
}

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>
注册
</title>
</head>
<body>
<form action="" method="POST">
<table align="center" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>用户名:</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="pwd"></td>
</tr>
<tr>
<td>密码确认:</td>
<td><input type="password" name="pwd1"></td>
</tr>
<tr>
<td>性别</td>
<td>
<input type="radio" name="select" value="男">男
<input type="radio" name="select" value="女">女
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="sure" value="确认">
<input type="reset" name="reset" value="取消">
</td>
</tr>
</table>
</form>
<?php
//include"commend.php";
$name =$_POST['name'];
$pwd=$_POST['pwd'];
$select =$_POST['select'];
function tt($t)
{
$conn=mysql_connect("127.0.0.1","root","");
$qurry= "select name from ut ";
$result = mysql_db_query("test",$qurry);
$arry=mysql_fetch_array($result);
$t=$arry[t];
return $t;
}
if($_POST['sure'])
{
if($_POST['name']=="")
{
$error="用户名空呀";
}
if((!isset($error))&(!ereg("^[0-9a-z]*$",$_POST['name'])))
{
$error="用户名只能是数字,字母和下划线";
}
if((!isset($error))&($t=$_POST['name']))
{
$error="用户名已经存在";
}
if((!isset($error))&($_POST['pwd']!=$_POST['pwd1']))
{
$error="2次密码不一致";
}
if(!isset($error))
{
$conn=mysql_connect("127.0.0.1","root","");
mysql_query('SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary', $conn);
$qurry= "insert into ut(name,pwd,sex)values('$name','$pwd','$select')";
$result = mysql_db_query("test",$qurry);
header("Location:on_ok.php?names=$name&pwd=$pwd");
}
else
{
ob_start();
header("Location:on_error.php?error=$error");
ob_end_flush();//输出全部内容到浏览器
}
exit;
}
?>
</body>
</html>
mysql_select_db("test",$conn);
$result = mysql_query($qurry);