У меня сложное время, когда моя страница перенаправляется после отправки формы. Я следовал совету, который мне удалось найти, и не повезло. Любая помощь будет принята с благодарностью.PHP Redirect Issue
<?php
//If the form is submitted
if(isset($_POST['submit'])) {
$subject = "CONTACT FORM";
//Check to make sure that the name field is not empty
if(trim($_POST['contactname']) == '') {
$hasError = true;
} else {
$name = trim($_POST['contactname']);
}
//Check to make sure sure that a valid email address is submitted
if(trim($_POST['email']) == '') {
$hasError = true;
} else {
$email = trim($_POST['email']);
}
//If there is no error, send the email
if(!isset($hasError)) {
$emailTo = '[email protected]';
$body = "Name: $name \nEmail: $email";
$headers = 'From: Bond Limo (Newsletter Signup) <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
}
?>
<?php if(isset($hasError)) { //If errors are found ?>
<p class="error">Please check if you've filled all the fields with valid information. Thank you.</p>
<?php } ?>
<?php if(isset($emailSent) && $emailSent == true) {
header("Location: http://www.website.com");
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" class="side-form">
Может быть, вы можете найти некоторую помощь здесь: http://stackoverflow.com/questions/768431/how-to-make -a-redirect-in-php? – Suprsonic
Возможный дубликат [Как я могу перенаправить в PHP без ошибок заголовка?] (Http://stackoverflow.com/questions/1255518/how-can-i-redirect-in-php-without-header-errors) –
-1 Не делайте никаких выходных данных перед заголовком. Его просили много раз, пожалуйста, сделайте лучшее исследование! –