//PHP简单做了个(包含4个文件,index.php,welcome.,reg.html)
------------------------------------------
// index.php
<?
$user=$_POST['uname'];
$pwd=$_POST['upwd'];
check($user,$pwd);
function check($u,$p){
$file = "";
if(file_exists($file)){
  $fhandle = fopen($file,"r");
  $flen = filesize($file);
  if($flen>0){
    $cont = fread($fhandle,$flen);
    fclose($fhandle);
    $split = explode("\n",$cont);
    foreach($split as $x){
    $up = explode(":",$x);
    if(trim($up[0])==$u&trim($up[1])==$p&strlen($u)>0&strlen($p)>0){
      //登入成功后,转到welcome.php
      echo '<script language="JavaScript">window.location.href="welcome.php";</script>';
      break;
    }
    }
    //登入不成功,要求登录
    include("reg.html");
  }
  else{
    echo "用户信息文件为空<br>";
  }
  }
else{
  echo "用户信息文件不存在<br>";
  }
}
?>
------------------------------------------
//welcome.php
<br/><h1 align=center><font color=blue>我是会员,我怕谁?</h1>
----------------------------------------------
//reg.html
<html>
<head>
  <title>register</title>
  </head>
  <body>
<form action=index.php method=post>
user:<input type=text size=20 name=uname id=uname/><br>
pwd: <input type=password size=20 name=upwd id=upwd /><br>
<button type=submit>submit</button>
</form>
</body>
</html>
-------------------------------------------
//
#html实现用户注册登录代码格式用户名:密码  (允许有空格)
a : a
b : b
c: c

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。