Answer the question
In order to leave comments, you need to log in
What is the correct way to redirect the user to the "Thank you for submitting" page after submitting the form?
Good evening. The site has a form for sending applications, sending is implemented using a php script. Here is the code
<?php
$mal = $_POST['email'];
$url = $_SERVER['HTTP_REFERER']."success";
if(!empty($mal))
{
$message = '';
$message .= 'Email: '.$mal."<br/>";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
mail("[email protected]", "Заявка", $message, $headers);
header("Location: $url");
}
?>
Answer the question
In order to leave comments, you need to log in
HTTP_REFERER should never be used in site mechanics.
The easiest way is to process all forms at the same address where they are shown.
If this is difficult, then write the return url in a hidden form field
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question