<?php
@session_start();
$user_name=$_POST['user_name'];
$name=$_POST['name'];
$password_one=$_POST['password_one'];
$password_two=$_POST['password_two'];
$sex=$_POST['sex'];
$age=$_POST['age'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$address=$_POST['address'];
if(strlen($user_name)<1)
{
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新用户注册页面</title>
<meta http-equiv=Content-Type content="text/html;charset=utf-8">
</head>
<body topmargin="15">
<center>
<font color="green" size="3">会员注册表单</font>
</center>
<form method="post" action="message.php">
<table width="60%" border=1 align="center" cellpadding="2">
<tr bgcolor="#6b8ba8" color="ffffff">
<td width="100%" align="center"colspan="2">请认真填写以下内容</td>
</tr>
<tr>
<td align="right">用户名:</td>
<td align="left"><input type="text" name="user_name"></input></td>
</tr>
<tr>
<td align="right">姓名:</td>
<td align="left"><input type="text" name="name"></input></td>
</tr>
<tr>
<td align="right">密码:</td>
<td align="left"><input type="password" name="password_one"></input></td>
</tr>
<tr>
<td align="right">重新输入密码:</td>
<td align="left"><input type="password" name="password_two"></input></td>
</tr>
<tr>
<td align="right">性别:</td>
<td align="left"><input type="radio" name="sex" value="1" checked>男</input>
<input type="radio" name="sex" value="2">女</input>
</td>
</tr>
<tr>
<td align="right">年龄:</td>
<td align="left"><input type="text" name="age" size="3" maxlength="2"></input></td>
</tr>
<tr>
<td align="right">联系电话:</td>
<td align="left"><input type="text" name="phone" size="16" maxlength="16"></input></td>
</tr>
<tr>
<td align="right">E-mail:</td>
<td align="left"><input type="text" name="email" size="20" maxlength="20"></input></td>
</tr>
<td align="right">地址:</td>
<td align="left"><input type="text" name="address" size="45" maxlength="50"></input></td>
</tr>
<td colspan="2" align="center">
<input type="submit" value="确认注册"></input>
<input type="reset" value="重新填写"></input>
<a href="login.htm">已经注册?</a>
</td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
else if(strlen($user_name)>1)
{
//echo $name."<br />";
if($sex=="1")
{
$sex="男";
}
else
{
$sex="女";
}
if(!$user_name)
{
echo "请输入用户名!";
exit;
}
if(!$name)
{
echo "请输入真实姓名!";
exit;
}
elseif(!$password_one)
{ echo "请输入密码!";
exit;
}
elseif(!$password_two)
{
echo "请确认密码!";
exit;
}
elseif($password_one != $password_two)
{
echo "两次密码输入不一致!";
exit;
}
elseif(!$age)
{
echo "请输入您的年龄!";
exit;
}
if(!$phone)
{
echo "请输入联系电话!";
exit;
}
elseif(!$email)
{
echo "请输入您的E-mail!";
exit;
}
elseif(!$address)
{
echo "请输入您的地址!";
exit;
}
$connect=mysql_connect("localhost","root","");
if(!$connect)
{
echo "无法链接服务器,请稍后再试.";
exit;
}
$select=mysql_select_db("liuyan",$connect);
if(!$select)
{
echo "无法链接数据库,请稍后再试.";
exit;
}
$name_name="select * from message where user_name='$user_name'";
$name_query=mysql_query($name_name);
$name_row=mysql_num_rows($name_query);
if($name_row >=1)
{
echo "您所注册的用户名已存在,请返回重新注册!";
exit;
}
$email_email="select * from message where email='$email'";
$email_query=mysql_query($email_email);
$email_row=mysql_num_rows($email_query);
if($email_row >=1)
{
echo "您所注册的邮箱已存在,请返回重新注册!";
exit;
}
$query="insert into message values('$user_name','$name','$password_one','$sex','$age','$phone','$email','$address')";
@ $row=mysql_query($query);
if(!row)
{
echo "注册失败,请重新注册.";
}
else
{
$_SESSION['user_name']=$user_name;
echo "<center><br><br>"."您已经成功注册成为我们的会员!"."<br><br>";
//echo $user_name;
echo "<a href='select_message.php?name=$user_name'>"."点击查看您的信息</a></center>";
}
}
?>