【发布时间】:2012-12-25 14:40:28
【问题描述】:
我想在 PHP 中自动重定向页面
注销.php:
<?php
include "base.php";
$_SESSION = array(); session_destroy();
?>
<meta http-equiv="refresh" content="=0;URL=index.php" />
base.php 在哪里调用数据库并启动会话:
<?php
session_start();
$dbhost = "localhost";
$dbname = "login";
$dbuser = "root";
$dbpass = "";
mysql_connect($dbhost, $dbuser, $dbpass) or die("MySQL Error: " . mysql_error());
mysql_select_db($dbname) or die("MySQL Error: " . mysql_error());
?>
按注销时,我没有回到index.php。
【问题讨论】:
-
Heads up about the
mysql_*functions。它们不再维护and are officially deprecated。看到red box?改为了解prepared statements,并使用PDO 或MySQLi - this article 将帮助您决定哪个。如果你选择 PDO,here is a good tutorial.