0
我在config.php文件中使用session_start()函數,並且此文件包含在所有文件中。在我的add_page.php頁面中,我提交表單並在會話中保存一條消息(在提交操作中),然後重定向到index.php頁面(使用頭('location:...'))。但在重新導演之後,我沒有收到會話中的消息。其他會話數據存在像用戶名,logged_in等任何想法?PHP會話問題
代碼波紋管(add_news.php)。提交表單後,它會重定向到news.php。 config.php文件已session_start()函數在頂部,它是包含在每一頁:
<?php
include('../include/config.php');
//submit edit data
if (isset($_POST['submit_edit'])) {
$news_head = stripslashes(trim($_POST['news_head']));
$news_details = $_POST['news_details'];
$news_special = ($_POST['news_special']=='')?'0':'1';
$news_status = ($_POST['news_status']=='')?'0':'1';
$data = array('news_head'=>$news_head,
'news_details'=>$news_details,
'news_special'=>$news_special,
'news_status'=>$news_status);
$clause = "news_id = '".$_POST['news_id']."'";
$response = update_data('news', $data, $clause);
if($response)
$_SESSION['success_msg'] = "News updated successfully.";
}
//submit edit data end
?>
<form action="add_news.php" method="post" id="add_news_form">
<input type="hidden" name="news_id" value="<?php echo $news_id ?>" />
<table width="100%" border="0" cellspacing="4" cellpadding="4">
<tr>
<td>News Heading</td>
<td><input type="text" name="news_head" id="news_head" class="required" value="<?php echo $news_head ?>" size="100" /></td>
</tr>
<tr>
<td>News Details</td>
<td><textarea name="news_details" id="news_details" class="editor required" rows="7" cols="60"><?php echo trim(stripslashes($news_details)); ?></textarea></td>
</tr>
<tr>
<td>Special News</td>
<td><input type="checkbox" name="news_special" id="news_special" value="1" <?php if($news_special=='1') echo 'checked="checked"'?> />
[ Checked means special ]</td>
</tr>
<tr>
<td>Status Status</td>
<td><input type="checkbox" name="news_status" id="news_status" value="1" <?php if($news_status=='1') echo 'checked="checked"'?> />
[ Checked means published ]</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Submit" <?php if($_REQUEST['news_id']!="" && $_REQUEST['action']=='edit') echo 'name="submit_edit"'; else echo 'name="submit"'; ?> /></td>
</tr>
</table>
</form>
如何顯示一些代碼? – 2011-02-26 17:37:40
請顯示一些代碼關於問題 – kjy112 2011-02-26 17:38:15
是的,需要看到一些代碼來解決這個問題。 – mcbeav 2011-02-26 17:38:35