I want to have a redirection (to index.php
, my homepage) when the message in my contact form has been sent but I don't see how to do it so I ask your precious help.
Here is my PHP code:
<?php
$to = "[email protected]";
$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$subject = $_REQUEST["subject"];
$msg = $_REQUEST["message"];
if (isset($email) && isset($name)) {
$website = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$headers = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "
";
$headers .= "From: ".$name." <".$email.">
"."Reply-To: ".$email."
" ;
$msg = "Bonjour Anne-Valérie, <br/> <br/> vous avez un nouveau message de $name ($email)<br/><br/>Message: $msg <br><br> -- <br>Cet email a été envoyé depuis $website";
$mail = mail($to, $subject, $msg, $headers);
if($mail)
{
echo 'Votre mail a bien été envoyé, une réponse vous sera apporté sous peu, merci de votre confiance.';
}
else
{
echo "Oups, quelque chose n'a pas fonctionné, veuillez vérifier vos informations.";
}
}
?>
question from:
https://stackoverflow.com/questions/65843136/make-a-redirection-to-homepage-after-message-send-with-php 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…