php会员管理系统
前台登录页面
<form action="session.php" method="POST"> 账 号:<input name="username" type="text" /><br><br> 密 码:<input name="password" type="password" /><br><br> <input name="sub" type="submit" value="登录" /> </form>
验证页面
<?php session_start(); include_once 'conn.php'; $username=$_POST['username']; $password=$_POST['password']; $sql="select * from data where username='".$username."' and password='".$password."'"; $query=mysql_query($sql); $row=mysql_fetch_array($query); $_SESSION['username']=$username; $_SESSION['password']=$password; if (!$row){ echo "<script language='javascript'>alert('用户名或密码错误!');location='index.php';</script>"; }else{ echo "<script language='javascript'>alert('登陆成功!');location='user.php';</script>"; } ?>
后台页面
<?php session_start(); if ($_SESSION['username']=="" ||$_SESSION['password'==""]){ echo "<script language='javascript'>alert('请先登录!');location='../index.php';</script>"; } ?> <?php $user = $_SESSION['username']; $conn=mysqli_connect("localhost","root","root"); $db=mysqli_select_db($conn,"rmb"); $sql="select * from data where username='".$user."'"; $re=mysqli_query($conn,$sql); $r=mysqli_fetch_array($re); echo "<br>"; echo "用户:".$_SESSION['username']." <a href='zx.php'>退出</a><br>; ?>