标头位置不在实时服务器上工作,但适用于localhost。
此代码一直工作到上周,但它不再起作用了。
所以,我已经开始在localhost上测试了。它像以前一样工作。
我尝试添加" ob_start()"在代码的顶部;不工作。
请查看此代码并发表评论。
<?php session_start();
$fnameErr ="";
$lnameErr ="";
$emailErr ="";
$phoneErr = "";
$dateErr = "";
$timeErr = "";
$errMsg = "";
$area = "";
$local3 = "";
$local4 = "";
$cust_info = "";
$charOnly = "/^[a-z]+[a-z]$/i";
$reg_email = "/^[^0-9~!@#$%^&*()_+=?.,][a-z0-9_]+([.][a-z0-9_]+)*[@][a-z0-9_]+([.][a-z0-9_]+)*[.][a-z]{2,3}$/i";
$reg_phone = "/^(\d{3}+\d{3}+\d{4}|\d{3}\d{3}+[\s]{1}+\d{4}|\d{3}+[\s]{1}+\d{3}+[\s]{1}+\d{4}||\d{3}+[-]{1}+\d{3}+[-]{1}+\d{4}|\d{3}+[\s]{1}+\d{7}|\(\d{3}\)\s{1}\d{3}[\s-]{1}\d{4})$/";/*"/^(\d{3}|[(]\d{3}[)]|\d{3}[)])[ -]*\d{3}[ -]*\d{4}$/";*/
$dataValid = true;
$phone = $area .''. $local3 .''. $local4;
$phoneValid = true;
// If submit with POST
if ($_POST) {
$errMsg = "Debugging";
$area = $_POST['c_area'];
$local3 = $_POST['c_local3'];
$local4 = $_POST['c_local4'];
$cust_info = array( "first" => $_POST['c_fname'],
"last" => $_POST['c_lname'],
"email" => $_POST['c_email'],
"phone" => array("area"=> $area,
"mid" => $local3,
"last" => $local4),
"date" => $_POST['c_date'],
"time" => $_POST['c_time']);
// Test for nothing entered in field
if ($_POST['c_fname'] == "") {
$fnameErr = "Please enter your first name.";
$dataValid = false;
}
else {
if ( preg_match($charOnly, $_POST['c_fname']) )
{
$fnameErr = "";
} else {
$fnameErr = "This is an invalid name.";
$dataValid = false;
}
}
if ($_POST['c_lname'] == "") {
$lnameErr = "Please enter your last name.";
$dataValid = false;
}
else {
if ( preg_match($charOnly, $_POST['c_lname']) )
{
$lnameErr = "";
} else {
$lnameErr = "This is an invalid name.";
$dataValid = false;
}
}
if ($_POST['c_email'] == "") {
$emailErr = "Please enter E-mail address.";
$dataValid = false;
}
else {
if ( preg_match($reg_email, $_POST['c_email']) )
{
$emailMsg = "";
} else {
$emailMsg = "E-mail is not Valid.";
$dataValid = false;
}
}
if ($_POST['c_area'] == "") {
$phoneErr = "Please enter phone number.";
$dataValid = false;
$phoneValid = false;
}
if ($_POST['c_local3'] == "") {
$phoneErr = "Please enter phone number.";
$dataValid = false;
$phoneValid = false;
}
if ($_POST['c_local4'] == "") {
$phoneErr = "Please enter phone number.";
$dataValid = false;
$phoneValid = false;
}
if( $phoneValid ) {
$phone = $area . "" . $local3 . "" .$local4;
if ( preg_match($reg_phone, $phone) ) {
$phoneErr = "";
} else {
$phoneErr = "Phone number is not Valid.";
$dataValid = false;
}
} else {
$area = "";
$local3 = "";
$local4 = "";
$phone = "";
}
if ($_POST['c_date'] == "") {
$dateErr = "Please choose a date.";
$dataValid = false;
}
if ($_POST['c_time'] == "" || $_POST['c_time'] == "Morning" || $_POST['c_time'] == "Afternoon") {
$timeErr = "Please choose a time.";
$dataValid = false;
} else {
if ("07:00" == $_POST['c_time']){
$Checked0700 = 'selected';
}
else if ("07:30" == $_POST['c_time']){
$Checked0730 = 'selected';
}
else if ("08:00" == $_POST['c_time']){
$Checked0800 = 'selected';
}
else if ("08:30" == $_POST['c_time']){
$Checked0830 = 'selected';
}
else if ("09:00" == $_POST['c_time']){
$Checked0900 = 'selected';
}
else if ("09:30" == $_POST['c_time']){
$Checked0930 = 'selected';
}
else if ("10:00" == $_POST['c_time']){
$Checked1000 = 'selected';
}
else if ("10:30" == $_POST['c_time']){
$Checked1030 = 'selected';
}
else if ("11:00" == $_POST['c_time']){
$Checked1100 = 'selected';
}
else if ("11:30" == $_POST['c_time']){
$Checked1130 = 'selected';
}
else if ("12:00" == $_POST['c_time']){
$Checked1200 = 'selected';
}
else if ("12:30" == $_POST['c_time']){
$Checked1230 = 'selected';
}
else if ("13:00" == $_POST['c_time']){
$Checked1300 = 'selected';
}
else if ("13:30" == $_POST['c_time']){
$Checked1330 = 'selected';
}
else if ("14:00" == $_POST['c_time']){
$Checked1400 = 'selected';
}
else if ("14:30" == $_POST['c_time']){
$Checked1430 = 'selected';
}
else if ("15:00" == $_POST['c_time']){
$Checked1530 = 'selected';
}
else if ("15:30" == $_POST['c_time']){
$Checked1530 = 'selected';
}
else if ("16:00" == $_POST['c_time']){
$Checked1600 = 'selected';
}
else if ("16:30" == $_POST['c_time']){
$Checked1630 = 'selected';
}
else if ("17:00" == $_POST['c_time']){
$Checked1700 = 'selected';
}
else if ("after" == $_POST['c_time']){
$Checkedafter = 'selected';
}
}
}
if ($_POST && $dataValid) {
$_SESSION['token1'] = "ok";
$_SESSION['cust'] = $cust_info;
header('Location:innout-booking-step2.php');
exit();
?>
答案 0 :(得分:1)
我也遇到了这样的问题,所以我尝试按照步骤来解决它
1.在调用标题位置之前删除或注释空格,回声,print_r,错误报告
2.删除php结束标记后的空格(在?&gt;之后)
3.修改标题位置语法,我通常做的是打开w3schools复制标题位置语法并粘贴它。在您的情况下,您应该尝试将标题代码更改为
header('Location: innout-booking-step2.php');
(后面的空格:)