我在我的课堂文件中设置会话消息,如,然后将页面重定向到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