PHP+Ajax无刷新登录与退出案例,记录登录IP,上次登录时间
XML/HTML Code
- <div id="container">
- <div class="demo">
- <p style="margin:20px">提示:用户名和密码都是 <b>admin</b>。</p>
- <div id="login">
- <h3>用户登录</h3>
- <?php
- @session_start();
- if (isset($_SESSION['user'])) {
- ?>
- <div id="result">
- <p><strong><?php echo $_SESSION['user']; ?></strong>,恭喜您登录成功!</p>
- <p>您这是第<span><?php echo $_SESSION['login_counts']; ?></span>次登录本站。</p>
- <p>上次登陆本站的时间是:<span><?php echo date('Y-m-d H:i:s', $_SESSION['login_time']); ?></span></p><p><a href='#' id='logout'>【退出】</a></p>
- </div>
- <?php } else { ?>
- <div id="login_form">
- <p><label>用户名:</label> <input type="text" class="input" name="user" id="user" /></p>
- <p><label>密 码:</label> <input type="password" class="input" name="pass" id="pass" /></p>
- <div class="sub">
- <input type="submit" class="btn" value="登 录" />
- </div>
- </div>
- <?php } ?>
- </div>
- </div>
- </div>
原文地址:http://www.freejs.net/article_biaodan_695.html