I'm trying redirect users to a thank you page after submitting a form but my header location doesn't seem to work (local or online). Nothing happens when clicking the submit button (the email is sent though).
My php looks like this :
<?php
$val= $_POST['val'];
$toemail='mail@mail.com';
$name = $val['name'];
$societe = $val['societe'];
$email = $val['email'];
$phone = $val['phone'];
$msg = $val['msg'];
$subject = 'Contact';
$headers = "From: $email \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
$message = "<b>Nom : </b>".$name."<br>";
$message .='<b>Societe : </b>'.$societe."<br>";
$message .='<b>Email : </b>'.$email."<br>";
$message .='<b>Telephone : </b>'.$phone."<br>";
$message .='<b>Message : </b>'.$msg;
mail($toemail, $subject, $message, $headers);
header("Location: http://example.com/thankyou.html");
?>
What am I doing wrong? Thanks in advance for your help.
Edit: Thanks for your help. If I turn error reporting I get: Warning : Cannot modify header information - headers already sent by (output started at /path/email.php:12)