PHP会员系统(3)

PHP会员系统(3)-用户注册以及登陆

这些教程来源于中国教程网  欢迎转载,转载本站文章请注明!否则必定追究责任! http://www.cnjiaocheng.com

如果你需要这个系统的代码请加入中国教程网PHP群:8920718

来源中国教程网

用户注册:reg.php页面代码 来源中国教程网

<?php
/*
@web 用户注册页面
@author yangfan
@2007/12/18/22:50
*/ http://www.cnjiaocheng.com

//调用主机信息
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>&nbsp;&nbsp";
  echo "<a href=/"index.php/">返回首页</a>&nbsp;&nbsp";
  echo "<a href=/"reg.php/">注册页面</a>";
  exit();
 }
}
http://www.cnjiaocheng.com


?>
<html>
 <head>
  <title>用户注册</title>
 </head>
 <body>
  用户注册:
  <hr size="1" color="#000" width="50%"align="left">
  <form action="reg.php" method="POST">
   用&nbsp;户&nbsp;名:
   <input type="text" id="username" name="username"size="15"><br>
   呢&nbsp;&nbsp;&nbsp;&nbsp;称:
   <input type="text" id="usernick" name="usernick"size="15"><br>
   密&nbsp;&nbsp;&nbsp;&nbsp;码:
   <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
 


http://www.cnjiaocheng.com


用户登陆:login.php页面代码 http://www.cnjiaocheng.com

<?php
/*
@web 用户登陆页面
@author yangfan
@2007/12/18/22:40
*/ 来源中国教程网

//调用主机信息
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/">"; http://www.cnjiaocheng.com
  echo "<a href=/"login.php/">登陆页面</a>&nbsp;&nbsp";
  echo "<a href=/"reg.php/">注册页面</a>&nbsp;&nbsp";
  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>
   密&nbsp;&nbsp;码:
   <input type="password" name="password" id="password" size="15"><br>
   <input type="submit" name="submit" id="submit" value="登陆">
   <input type="reset">
  </form>
 </body>
</html> http://www.cnjiaocheng.com
 
http://www.cnjiaocheng

本篇文章来源于中国教程网(www.cnjiaocheng.com)教程地址:http://www.cnjiaocheng.com/phprumen/20080512/766.html

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值