如何在php的注销页面中使用会话。 [英] How to use session in log out page in php.

查看:72
本文介绍了如何在php的注销页面中使用会话。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

有人请帮助我:(

我在登出页面时遇到问题。



我有文件logout.php。我想在用户从系统注销后,日期和时间必须保存在数据库中,但不幸的是数据没有保存在数据库中。

任何人都可以告诉我怎么做?



谢谢。

Hello everyone,
Someone please help me :(
I'm having problems in doing logout page.

I have file logout.php. I want after the user logout from the system, the date and time must save in database, but unfortunately the data does not save in database.
Anyone can show me how to do it?

Thank you.

推荐答案

用于以下代码。<这是你想要的吗?



Use for the below code.
Is this what you want?

<?php
session_start();

// check that the session exists first
if(isset(


_SESSION [' 用户名'])){

// 你应该把您在config.php文件中的数据库连接并使用mysqli或PDO - 你正在使用的是折旧的
mysql_connect( localhost root die( 无法连接);
mysql_select_db( db name die( 无法选择DB);

// 我认为我不会在会话中存储密码...
// 还有,数据库中的用户名是UNIQUE吗?
// 另外,总是逃避(清理)数据库输入以防止再次SQL注入

_SESSION['username'])) { // you should put your db connection in a config.php file and use mysqli or PDO - what you're using is depreciated mysql_connect("localhost", "root", "") or die("cannot connect"); mysql_select_db("db name") or die("cannot select DB"); // don't think I'd store password in a session... // also, is username UNIQUE in your database? // also, also, ALWAYS escape (sanitize) your database input to prevent agains SQL injection


sql = SELECT用户名,密码
FROM
用户
WHERE
用户名='
.mysql_real_escape_string(
sql = "SELECT username, password FROM users WHERE username = '".mysql_real_escape_string(


这篇关于如何在php的注销页面中使用会话。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆