【发布时间】:2013-05-11 02:58:55
【问题描述】:
我的 PHP 注销脚本有问题,我有以下代码:
<?php
session_start();
//redirect function
function returnheader($location){
$returnheader = header("location: $location");
return $returnheader;
}
$connection = mysql_connect("localhost","username","password") OR die(mysql_error());
$db_select = mysql_select_db("database",$connection) OR die(mysql_error());
// destroy cookies and sessions
setcookie("userloggedin", "");
$username = "";
session_destroy();
//redirect
returnheader("index.php");
?>
我不断收到以下错误:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'loginuser'@'localhost' (using password: YES) in logout.php on line 10
用户 'loginuser'@'localhost' 的访问被拒绝(使用密码:YES)
任何人都可以帮助我是 php 新手,并且可能会咬得比我能咀嚼的更多:)
【问题讨论】:
-
您是否验证了您用于连接的参数在其他地方工作?如果是这样,怎么做?注意 MySQL 将 'localhost' 视为特殊情况 - 它不通过网络连接到 127.0.0.1,它使用文件系统套接字。
-
使用会话在php中登录和注销:allitstuff.com/login-and-logout-in-php-using-session
标签: php login logout server-side-scripting