my.php 是用户中心,列在教程里作为用户登录检测参考。
<?php session_start(); //检测是否登录,若没登录则转向登录界面 if(!isset($_SESSION['userid'])){ header("Location:login.html"); exit(); } //包含数据库连接文件 include('conn.php'); $userid = $_SESSION['userid']; $username = $_SESSION['username']; $user_query = mysql_query("select * from user where uid=$userid limit 1"); $row = mysql_fetch_array($user_query); echo '用户信息:<br />'; echo '用户ID:',$userid,'<br />'; echo '用户名:',$username,'<br />'; echo '邮箱:',$row,'<br />'; echo '注册日期:',date("Y-m-d", $row['regdate']),'<br />'; echo '<a href="login.php?action=logout">注销</a> 登录<br />'; ?>