Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP标题重定向到错误页面_Php_Redirect - Fatal编程技术网

PHP标题重定向到错误页面

PHP标题重定向到错误页面,php,redirect,Php,Redirect,我正在尝试在表单提交后进行标题重定向。并且重定向发生,但是它重定向到index.html而不是指定的页面。我做错了什么?我已经将我的代码包含到PHP中,如下表所示 请参阅下面我的代码: <?php //Autoresponder Section $email = $_REQUEST['email']; $to = $email; $subject = "Thank You For Choosing Us!"; $EmailFrom = $email; $message = " <

我正在尝试在表单提交后进行标题重定向。并且重定向发生,但是它重定向到index.html而不是指定的页面。我做错了什么?我已经将我的代码包含到PHP中,如下表所示

请参阅下面我的代码:

<?php

//Autoresponder Section
$email = $_REQUEST['email'];
$to = $email;
$subject = "Thank You For Choosing Us!";
$EmailFrom = $email;


$message = "
<html>
<head>
<title>Thank you for choosing Us!</title>
</head>
<body>
Hello!
Thank you for choosing Us! 
<br>
As a small family business your satisfaction and feed back is very important to us. 

Please give us your honest opinion and receive $5 towards your next treatment:

<a href='http://page.com'><b>LOVED IT</b></a>    or  <a href='mailto:info@doamin.com?Subject=Feedback%20on%20my%20recent%20service%20at%20BSC' target='_top'><b>COULD IMPROVE</b></a>

</body>
</html>
";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: <info@domain.com>' . "\r\n";

mail($to,$subject,$message,$headers);


$dontsendemail = 0;
$possiblespam = FALSE;
$strlenmessage = "";
$email = $_REQUEST['email']; 
$subject = "Consent Form Submission"; $emailaddress = "email@me.com"; /* NOTE: Although your email address is visible here in this code, the person contacting you will never see this email address. Your email address will remain on your server, and it will not be sent from your server to the person contacting you. It will also remain invisible to spam bots. Your email address  is also never stored on any of our servers. You can choose to delete or not delete this note when you publish this page. It will not change the functionality of the contact form. */

// Check human test input box
if(isset($_REQUEST["htest"]) && $_REQUEST["htest"] != "") die("Possible spam detected. Please hit your browser back button and check your entries."); 
// Check email address function
function checkemail($field) {
    // checks proper syntax
    if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $field))
    {
        die("Improper email address detected. Please hit your browser back button and enter a proper email address."); 
        return 1;
    }
}
// Check month function
function checkmonth($field,$checkrequiredob) {
    if($checkrequiredob == 0) {
        if(!preg_match("/^[\s]{0,5}$|^(0|January|February|March|April|May|June|July|August|September|October|November|December)$/", $field)) die("Improper month of birth detected. Please hit your browser back button and try again.");  
    }
    else {
        if(!preg_match("/^(January|February|March|April|May|June|July|August|September|October|November|December)$/", $field)) die("Improper month of birth detected. Please hit your browser back button and try again."); 
    }
}
// Spamcheck function
function spamcheck($field) {
    if(preg_match("/to:/i",$field) || preg_match("/cc:/i",$field) || preg_match("/\r/i",$field) || preg_match("/i\n/i",$field) || preg_match("/%0A/i",$field)){ 
        $possiblespam = TRUE;
    }else $possiblespam = FALSE;
    if ($possiblespam) {
        die("Possible spam attempt detected. If this is not the case, please edit the content of the contact form and try again.");
        return 1;
    }
}
// Spamcheck URL function
function spamcheckurl($field) {
    if(preg_match("/to:/i",$field) || preg_match("/cc:/i",$field) || preg_match("/\r/i",$field) || preg_match("/\n/i",$field)){ 
        $possiblespam = TRUE;
    }else $possiblespam = FALSE;
    if ($possiblespam) {
        die("Possible spam attempt detected. If this is not the case, please edit the content of the contact form and try again.");
        return 1;
    }
}
function strlencheck($field,$minlength,$maxlength,$minresponse,$maxresponse) {
    if (strlen($field) < $minlength){
        die($minresponse); 
        return 1;
    }
    if (strlen($field) > $maxlength){
        die($maxresponse); 
        return 1;
    }
}
function checkphone($field,$checkrequirephone,$warning) {
    if($checkrequirephone == 0) {
        if(!preg_match("/^([\s]{0,10})$|^(((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?)(((\d{1,12}){1})|((\d{3,4}([-\s\.])?){2,3})){1}([\s]{0,10}))$/", $field)) die($warning);
    }       
    else {
        if(!preg_match("/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?)(((\d{1,12}){1})|((\d{3,4}([-\s\.])?){2,3})){1}([\s]{0,10})$/", $field)) die($warning);
    }
}
function checkpriority($field,$checkrequirepriority) {
    if($checkrequirepriority == 0) {
        if(!preg_match("/^[\s]{0,10}$|^[\d]$/",$field)) die("Improper priority detected. Please hit your browser back button and try again.");
    }
    else {
        if(!preg_match("/^[\d]$/",$field)) die("Improper priority detected. Please hit your browser back button and try again.");
    }
}

    $firstname = $_REQUEST['firstname'];strlencheck($firstname,0,60,"You have not entered a proper name. Please hit your browser back button and check your name entry.","You have entered a name that is too long. Please hit your browser back button and check your name entry.");$phone = $_REQUEST['phone'];checkphone($phone,0,"Improper first phone number detected. Please hit your browser back button and try again."); if ($dontsendemail == 0) $dontsendemail = spamcheck($_REQUEST["htest"]);
if ($dontsendemail == 0) $dontsendemail = spamcheck($firstname);
if ($dontsendemail == 0) $dontsendemail = spamcheck($phone);

if ($dontsendemail == 0) $dontsendemail = checkemail($email);
if ($dontsendemail == 0) $dontsendemail = spamcheck($email);
if ($dontsendemail == 0) $dontsendemail = spamcheck($subject);
if ($dontsendemail == 0) $dontsendemail = strlencheck($email,10,255,"The email address field is too short. Please hit your browser back button and check your entry.<br />","The email address you have entered is too long. Please hit your browser back button and check your entry."); //NOTE: An extremely small number of people worldwide have email addresses that are shorter than 10 characters. Though they exist, I as a webmaster who receives 200 emails per day have never seen a valid email address that was shorter than 12 characters. However, email addresses of length 13 characters are fairly common. I recommend that you do not reduce the 10 unless you plan on using internal emails from a business that has short email addresses, but that you do not raise the 10 so that you can avoid accidentally eliminating real contacts. Feel free to delete this message when you read it. It will not reduce the functionality of this contact form.


if ($dontsendemail == 0) $dontsendemail = strlencheck($emailaddress,8,255,"You have not selected a recipient of your message. Please hit your browser back button and check your entry.<br />","Possible spam detected. Please hit your browser back button and choose a recipient for your email.");
if ($dontsendemail == 0) {
    $staffmessage="";
    $staffmessage.="First Name: ".$firstname."\r\n";
    $staffmessage.="Last Name: ".$lastname."\r\n";
    $staffmessage.="Email: ".$email."\r\n";
    $staffmessage.="Phone Number: ".$phone."\r\n";

    mail($emailaddress,"$subject",$staffmessage,"From: $email" ); 
    include "email_sent.php";

    header('Location: /contact-thanks.html');
    exit;
} 

里面有什么
包括“email\u sent.php”
?这可能很幼稚,但应该是“Location:contact thanking.html”吗?my sites的header()语句都没有正向slashPlus,如果
/contact Thank.html
不在您的根目录中或不在当前位置,并且您的404设置已设置为根目录的页面,那么这就可以解释它了。如果你的主页是
index.html
,那么就可以了。这不是答案,但你只需要检查
$dontsendemail
一次:
如果($dontsendemail){//在这里做点什么}
,我猜你在
中做的任何事情都包括“email\u sent.php”正在浏览器中输出内容。您不能这样做,然后执行
header()
,因为
header()
只有在尚未向浏览器发送任何内容时才起作用。