<?php
error_reporting(0);
$username=$_GET["username"];
$passwd=$_GET["pswd"];
$passwd1=$_GET["pswd1"];
$ty=$_GET["ty"];
if ($username==""||$passwd==""||$passwd1=="") {
echo"<script>alert('用户名和密码不能为空!')</script>";
header("refresh:0;url=zhuce.html");
die();
}
if ($ty=="") {
echo"<script>alert('请同意网站协议!')</script>";
header("refresh:0;url=zhuce.html");
die();
}
if($passwd!=$passwd1){
echo"<script>alert('密码与前面不一致')</script>";
header("refresh:0;url=zhuce.html");
}
$link=mysql_connect("127.0.0.1","root","root")
or die("数据库服务器连接失败!<BR>");
mysql_select_db("pptonline",$link) or die("数据库选择失败!<BR>");
mysql_query("set names 'gbk'");
$sql="select username from userxinxi where username='$username'";
$result=mysql_query($sql,$link);
$row = mysql_fetch_array($result);
if ($row) {
echo"<script>alert('此用户名已经存在!')</script>";
header("refresh:0;url=zhuce.html");
}
$sql="INSERT INTO userxinxi(username,passwd,sf)
VALUES('$username',password('$passwd'),'用户')";
if (mysql_query($sql,$link)){
echo "<script>alert('恭喜您成为新用户!')</script>";
header("refresh:0;url=login.php");}
else{
echo "<script>alert('用户注册失败!')</script>";
header("refresh:0;url=login.php");}
?>
相似问题