PHP会员系统(3)
时间:2008-05-12 18:30:48
来源:
作者:
PHP会员系统(3)-用户注册以及登陆
这些教程来源于中国教程网 欢迎转载,转载本站文章请注明!否则必定追究责任!
http://www.cnjiaocheng.com
如果你需要这个系统的代码请加入中国教程网PHP群:8920718 http://www.cnjiaocheng.com
用户注册:reg.php页面代码
http://www.cnjiaocheng.com
|
<?php /* @web 用户注册页面 @author yangfan @2007/12/18/22:50 */ 来源中国教程网
//调用主机信息 include ("config.php"); //是否点击注册 if($submit){ //接受传递过来的值 $username = $_POST['username']; $usernick = $_POST['usernick']; $password = $_POST['password']; $rpassword = $_POST['password']; $i=0; if(!$username){ echo "<script> alert(\"用户名不能为空\"); </script>"; $i++; } if(!$usernick){ echo "<script> alert(\"呢称不能为空\"); </script>"; $i++; } if(strlen($password)<6||($password!=$rpassword)){ echo "<script> alert(\"密码长度要大于6\\n2次输入密码要一致\"); </script>"; $i++; } if($i==0){ //传入数据到数据库 $id = mysql_insert_id(); //自动获取数据库最后一个数据的ID+1 http://www.cnjiaocheng.com $updata = "insert into members (id,username,password,usernick) values('".$id."','".$username."','".$password."','".$usernick."')"; $result = mysql_query($updata); mysql_close(); echo "$usernick:恭喜你注册成功!"; echo "<hr size=\"1\" color=\"#000\" width=\"50%\" align=\"left\">"; echo "<a href=\"login.php\">登陆页面</a>  "; echo "<a href=\"index.php\">返回首页</a>  "; echo "<a href=\"reg.php\">注册页面</a>"; exit(); } } 来源中国教程网
?> <html> <head> <title>用户注册</title> </head> <body> 用户注册: <hr size="1" color="#000" width="50%"align="left"> <form action="reg.php" method="POST"> 用 户 名: <input type="text" id="username" name="username"size="15"><br> 呢 称: <input type="text" id="usernick" name="usernick"size="15"><br> 密 码: <input type="password" id="password" name="password"size="15"><br> 重复密码: http://www.cnjiaocheng.com <input type="password" id="rpassword" name="rpassword"size="15"><br> <input type="submit" id="submit" name="submit" value="注册"> <input type="reset"> </form> </body> </html> http://www.cnjiaocheng.com
|
来源中国教程网
用户登陆:login.php页面代码 http://www.cnjiaocheng.com
|
<?php /* @web 用户登陆页面 @author yangfan @2007/12/18/22:40 */ http://www.cnjiaocheng.com
//调用主机信息 include ("config.php"); 来源中国教程网
//获取表单传递过来的值 $username = $_POST['username']; $password = $_POST['password']; if($username){ $o = "SELECT * FROM members where username = '$username' AND password = '$password' "; $r = mysql_query($o); $i = 0; while($row=mysql_fetch_object($r)){ $i++; } if($i!=0){ echo "登陆成功!"; echo "<hr size=\"1\" color=\"#000\" width=\"50%\" align=\"left\">"; echo "<a href=\"index.php\">返回首页</a>"; exit(); } else{ echo "用户名或密码不正确,请重新登陆:<br>"; echo "<hr size=\"1\" color=\"#000\" width=\"50%\" align=\"left\">"; 来源中国教程网 echo "<a href=\"login.php\">登陆页面</a>  "; echo "<a href=\"reg.php\">注册页面</a>  "; echo "<a href=\"index.php\">返回首页</a>"; exit(); } } ?> 来源中国教程网
<html> <head> <title>用户登陆</title> </head> <body> 用户登陆: <hr size="1" color="#000" width="50%"align="left"> <form action="login.php" method="POST"> 用户名: <input type="text" name="username" id="username" size="15"><br> 密 码: <input type="password" name="password" id="password" size="15"><br> <input type="submit" name="submit" id="submit" value="登陆"> <input type="reset"> </form> </body> </html> 来源中国教程网
|
来源中国教程网