2011-11-11 163 views
1

我现在有一个简单的本地主机网站。我正在处理安全问题。我在数据库中创建了一个额外的列,并将其命名为enum('0','1')类型的“active_notactive”。PHP注销cookie和会话

我的问题:如何将active_notactive费尔德更改为0对特定用户的注销。

我想实现的是:在,active_notactive = '0' 在用户登录之前,之后便登录active_notactive = '1',当他们注销= '0'。我把他们全部从注销位开始工作。

这里是我的注销脚本:

<?php 
// start session 
session_start(); 



// HERE IS WHERE IM STUCK 
// get session email to use it in the following query 
$_SESSION['email'] = $email; 
// Update member to active 
mysql_query("UPDATE members SET active_notactive='0' WHERE email=$email"); 




// delete the current dession 
unset($_SESSION); 
session_destroy(); 

// set the current cookie to 1 hour ago (to delete it) 
setcookie ("online_security_user", "", time() - 3600); 
setcookie ("online_security_pass", "", time() - 3600); 

?> 

<h2>Thank you for using our website. You are now logged out.</h2> 
+0

**从不**假定查询成功。如果你有基本的错误处理,例如'mysql_query(...)或死(mysql_error())'你会看到为什么这不起作用。 –

回答

0
mysql_query("UPDATE members SET active_notactive='0' WHERE email='".$email."'"); 

$ email需要用引号括起来,因为它是字符串。

,也高于所需的答案$email= $_SESSION["email"]

+0

YESSSSSSSSSSSSSSSSSS!我爱你LOL –

1

什么不起作用?

我想你的意思$email = $_SESSION['email'];

+0

它不数据库将其更改为“0”上登出:( –

+0

然后开始调试。在执行前打印查询,启用错误报告,如果你得到错误的样子。 – CodeCaster