我在我的課堂文件中設置會話消息,如,然後將頁面重定向到header("location:news.php");
頁面重定向到news.php
,但會話消息未顯示。無法在PHP中顯示會話消息?
的config.php:
<?php
session_start();
// DATABASE CONFIURATION GOES HERE
?>
news.php:
<?php
require_once 'config.php';
require_once 'classes/class.news.php';
$objNews = new News();
if(isset($_POST['submit']) && $_POST['submit'] == 'add')
$objNews->add();
?>
<span class='text-warning'><?php echo $_session['op_status']; ?></span>
class.news.php:
public function add() {
if(){
// SOME CODE GOES HERE
} else {
$_SESSION['op_status'] == 'Already Exist';
}
}
你在這兩個文件中使用它之前,你開始你的會議? ('session_start();') – Rizier123 2015-01-04 14:21:28
是的,我在配置文件中添加了session_start(),並將配置文件包含在新聞文件中。 require_once( '的config.php'); – Butterfly 2015-01-04 14:23:29
然後請在這裏向我們展示這兩個腳本 – Rizier123 2015-01-04 14:23:54