我有用于发送邮件的 php 脚本,在这个脚本的末尾我重定向到“谢谢页面”。但我有问题。如果我在页面上提交邮件表单,邮件发送正确但重定向不起作用,但如果我直接去邮件发送脚本重定向的地址工作正常。
错误在哪里?
<?php
include('includes/config.php');
if(isset($_POST['Email_Orderer_Form'])) {
$headers = "From: xy@xy.com\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/plain; charset=utf-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Return-Path: xy@xy.com\n";
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = " xy@xy.com, ".$_POST['Email_Orderer_Form'].""; // This email address will recieve the data of form.html
$email_subject = "XY"; // This would be the subject of email that you will recieved
$White_PHP = $_POST['checkboxWhite'];
$White_Velikost_PHP = $_POST['White_Velikost_Form'];
$White_Ks_PHP = $_POST['White_Ks_Form'];
$Black_PHP = $_POST['checkboxBlack'];
$Black_Velikost_PHP = $_POST['Black_Velikost_Form'];
$Black_Ks_PHP = $_POST['Black_Ks_Form'];
$Jmeno_PHP = $_POST['Jmeno_Form'];
$Prijmeni_PHP = $_POST['Prijmeni_Form'];
$Ulice_PHP = $_POST['Ulice_Form'];
$Cislo_Popisne_PHP = $_POST['Cislo_Popisne_Form'];
$Mesto_PHP = $_POST['Mesto_Form'];
$PSC_PHP = $_POST['PSC_Form'];
$Email_Orderer_PHP = $_POST['Email_Orderer_Form'];
$Telefon_PHP = $_POST['Telefon_Form'];
$Komentar_PHP = $_POST['Komentar_Form'];
function clean_text($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$Stav = "New";
$White_PHP = mysql_real_escape_string($White_PHP);
$White_Velikost_PHP = mysql_real_escape_string($White_Velikost_PHP);
$White_Ks_PHP = mysql_real_escape_string($White_Ks_PHP);
$Black_PHP = mysql_real_escape_string($Black_PHP);
$Black_Velikost_PHP = mysql_real_escape_string($Black_Velikost_PHP);
$Black_Ks_PHP = mysql_real_escape_string($Black_Ks_PHP);
$Jmeno_PHP = mysql_real_escape_string($Jmeno_PHP);
$Prijmeni_PHP = mysql_real_escape_string($Prijmeni_PHP);
$Ulice_PHP = mysql_real_escape_string($Ulice_PHP);
$Cislo_Popisne_PHP = mysql_real_escape_string($Cislo_Popisne_PHP);
$Mesto_PHP = mysql_real_escape_string($Mesto_PHP);
$PSC_PHP = mysql_real_escape_string($PSC_PHP);
$Email_Orderer_PHP = mysql_real_escape_string($Email_Orderer_PHP);
$Telefon_PHP = mysql_real_escape_string($Telefon_PHP);
$Komentar_PHP = mysql_real_escape_string($Komentar_PHP);
if (($_POST['checkboxWhite'] == 'Bílé tričko') && ($_POST['checkboxBlack'] == 'Černé tričko')) {
$email_message .= "Objednávka\n";
$email_message .= "Tričko 1: ".clean_text($White_PHP)."\n";
$email_message .= "Velikost: ".clean_text($White_Velikost_PHP)."\n";
$email_message .= "Kusů: ".clean_text($White_Ks_PHP)."\n\n";
$email_message .= "Tričko 2: ".clean_text($Black_PHP)."\n";
$email_message .= "Velikost: ".clean_text($Black_Velikost_PHP)."\n";
$email_message .= "Kusů: ".clean_text($Black_Ks_PHP)."\n\n";
$email_message .= "Odběratel\n";
$email_message .= "Jméno: ".clean_text($Jmeno_PHP)."\n";
$email_message .= "Příjmení: ".clean_text($Prijmeni_PHP)."\n";
$email_message .= "Ulice: ".clean_text($Ulice_PHP)."\n";
$email_message .= "Číslo popisné: ".clean_text($Cislo_Popisne_PHP)."\n";
$email_message .= "Město: ".clean_text($Mesto_PHP)."\n";
$email_message .= "PSČ: ".clean_text($PSC_PHP)."\n";
$email_message .= "Email: ".clean_text($Email_Orderer_PHP)."\n";
$email_message .= "Telefon: ".clean_text($Telefon_PHP)."\n";
$email_message .= "Komentář: ".clean_text($Komentar_PHP)."\n";
mysql_query("INSERT INTO objednavky (Tricko1,Tricko1Velikost,Tricko1Ks,Tricko2,Tricko2Velikost,Tricko2Ks,Jmeno,Prijmeni,Ulice,CisloPopisne,Mesto,PSC,Email,Telefon,Zprava,Stav)
VALUES ('$White_PHP','$White_Velikost_PHP','$White_Ks_PHP','$Black_PHP','$Black_Velikost_PHP','$Black_Ks_PHP','$Jmeno_PHP','$Prijmeni_PHP','$Ulice_PHP','$Cislo_Popisne_PHP','$Mesto_PHP','$PSC_PHP','$Email_Orderer_PHP','$Telefon_PHP','$Komentar_PHP','$Stav')")or die(mysql_error());
}
else {
if ($_POST['checkboxWhite'] == 'Bílé tričko') {
$Black_PHP = "-";
$Black_Velikost_PHP = "-";
$Black_Ks_PHP = "-";
$email_message .= "Objednávka\n";
$email_message .= "Tričko: ".clean_text($White_PHP)."\n";
$email_message .= "Velikost: ".clean_text($White_Velikost_PHP)."\n";
$email_message .= "Kusů: ".clean_text($White_Ks_PHP)."\n\n";
$email_message .= "Odběratel\n";
$email_message .= "Jméno: ".clean_text($Jmeno_PHP)."\n";
$email_message .= "Příjmení: ".clean_text($Prijmeni_PHP)."\n";
$email_message .= "Ulice: ".clean_text($Ulice_PHP)."\n";
$email_message .= "Číslo popisné: ".clean_text($Cislo_Popisne_PHP)."\n";
$email_message .= "Město: ".clean_text($Mesto_PHP)."\n";
$email_message .= "PSČ: ".clean_text($PSC_PHP)."\n";
$email_message .= "Email: ".clean_text($Email_Orderer_PHP)."\n";
$email_message .= "Telefon: ".clean_text($Telefon_PHP)."\n";
$email_message .= "Komentář: ".clean_text($Komentar_PHP)."\n";
mysql_query("INSERT INTO objednavky (Tricko1,Tricko1Velikost,Tricko1Ks,Tricko2,Tricko2Velikost,Tricko2Ks,Jmeno,Prijmeni,Ulice,CisloPopisne,Mesto,PSC,Email,Telefon,Zprava,Stav)
VALUES ('$White_PHP','$White_Velikost_PHP','$White_Ks_PHP','$Black_PHP','$Black_Velikost_PHP','$Black_Ks_PHP','$Jmeno_PHP','$Prijmeni_PHP','$Ulice_PHP','$Cislo_Popisne_PHP','$Mesto_PHP','$PSC_PHP','$Email_Orderer_PHP','$Telefon_PHP','$Komentar_PHP','$Stav')")or die(mysql_error());
}
if ($_POST['checkboxBlack'] == 'Černé tričko') {
$White_PHP = "-";
$White_Velikost_PHP = "-";
$White_Ks_PHP = "-";
$email_message .= "Objednávka\n";
$email_message .= "Tričko: ".clean_text($Black_PHP)."\n";
$email_message .= "Velikost: ".clean_text($Black_Velikost_PHP)."\n";
$email_message .= "Kusů: ".clean_text($Black_Ks_PHP)."\n\n";
$email_message .= "Odběratel\n";
$email_message .= "Jméno: ".clean_text($Jmeno_PHP)."\n";
$email_message .= "Příjmení: ".clean_text($Prijmeni_PHP)."\n";
$email_message .= "Ulice: ".clean_text($Ulice_PHP)."\n";
$email_message .= "Číslo popisné: ".clean_text($Cislo_Popisne_PHP)."\n";
$email_message .= "Město: ".clean_text($Mesto_PHP)."\n";
$email_message .= "PSČ: ".clean_text($PSC_PHP)."\n";
$email_message .= "Email: ".clean_text($Email_Orderer_PHP)."\n";
$email_message .= "Telefon: ".clean_text($Telefon_PHP)."\n";
$email_message .= "Komentář: ".clean_text($Komentar_PHP)."\n";
mysql_query("INSERT INTO objednavky (Tricko1,Tricko1Velikost,Tricko1Ks,Tricko2,Tricko2Velikost,Tricko2Ks,Jmeno,Prijmeni,Ulice,CisloPopisne,Mesto,PSC,Email,Telefon,Zprava,Stav)
VALUES ('$White_PHP','$White_Velikost_PHP','$White_Ks_PHP','$Black_PHP','$Black_Velikost_PHP','$Black_Ks_PHP','$Jmeno_PHP','$Prijmeni_PHP','$Ulice_PHP','$Cislo_Popisne_PHP','$Mesto_PHP','$PSC_PHP','$Email_Orderer_PHP','$Telefon_PHP','$Komentar_PHP','$Stav')")or die(mysql_error());
mysql_Close();
}
}
@mail($email_to, $email_subject, $email_message, $headers);
}
header('Location: order_send.php');
die();
?>