[英]Redirect to another page after pressing submit button php mysql
填寫完表格並按下“提交”按鈕后,我將重定向到下一頁。 該代碼在Windows服務器上運行良好,但無法重定向到Linux服務器上的下一頁
<?php
include 'scripts/functions/init.php';
Restrict();
?>
<?php
$userid = $_SESSION['userid'];
if (empty($_POST)=== false)
{
$R_fields = array('OFO_Code','OFO_Title','Curr_Code','Curr_Title');
foreach($_POST as $key=>$value)
{
if (empty($value) && in_array($key,$R_fields)=== true)
{
$errors[] = 'fields marked with (*) are required';
break 1;
}
}
$_SESSION['Combo'] = $_SESSION['OFO_Code'].$_SESSION['Curr_Code'];
if(empty($errors)=== true)
{
if(Curr_Code_exists($_SESSION['Combo']))
{
$errors[] = 'Sorry, the Curriculum Code already exist, please use the edit function';
}
if(strlen('Curr_Code')<6)
{
$errors[] ='Curriculum Code must be at least 6 Characters';
}
}
}
?>
上面的代碼出現在html之前,然后是表格。 然后緊隨在提交按鈕之后,以下內容也位於
<?php
$_SESSION['OFO_Code'] = $_POST['OFO_Code'];
$_SESSION['Curr_Code'] = $_POST['Curr_Code'];
if(empty($_POST) === false && empty($errors)=== true)
{
//Capture data from the fields to an array
$Capture_Occupation_info = array(
'OFO_Code' => $_SESSION['OFO_Code'],
'OFO_Title'=>$_POST['OFO_Title'],
'Curr_Code'=>$_SESSION['Combo'],
'Curr_Title'=>$_POST['Curr_Title'],
'userid'=>$userid);
//Submit the data into the database
capture_occupation_info($Capture_Occupation_info);
header('Location:Capture_Menu.php');
exit();
}
else
{
//Display errors
echo output($errors);
}
?>
這是黑暗中的完整鏡頭,但可能正確。 Windows不區分大小寫,但NIX區分大小寫。
Capture_Menu.php
這正是在UNIX機器上大寫的方式嗎?
此外,在執行標頭重定向之前,您將無法顯示或向瀏覽器回顯。 請檢查是否有回聲,甚至在出現諸如?之后丟失空白
我以前進行過重定向不起作用,因為我的代碼將某些內容打印到了我沒有故意做的輸出中。
你可以試試這個...
error_reporting(E_ALL);
ini_set('display_errors', 'On');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.