I have two scenarios for my form that will determine if the submission is successful or failed. Either outcome serves the user with a unique page. I am looking for a way that the successful submissions are emailed to group A email addresses and the failed submissions are sent to Group B email addresses.
Here is my code:
<?php session_start();
if(isset($_POST['Submit'])) {
$from=$_POST['empty'];
$to=$_POST['empty'];
$subject=$_POST['empty'];
$text=$_POST['empty'];
$html=$_POST['empty'];
$file=$_POST['empty'];
$mimetype=$_POST['empty'];
$host=$_POST['empty'];
$username=$_POST['empty'];
$password=$_POST['empty'];
$Q1=$_POST['Q1'];
$Q2=$_POST['Q2'];
$Q3=$_POST['Q3'];
$Q4=$_POST['Q4'];
$fromsubject = 'sample-subject';
$firstname = $_POST['firstname'];
$mail = $_POST['mail'];
$phonenumber = $_POST['phonenumber'];
$to = 'myemail@gmail.com';
$header = "From: <" . $mail . ">\r\n"; //optional headerfields
$mailsubject = 'Message recived from sample site';
$body = $fromsubject.'
The person that contacted you is '.$firstname.'
Phone number: '.$phonenumber.'
E-mail: '.$mail.'
Q1: '.$Q1.'
Q2: '.$Q2.'
Q3: '.$Q3.'
Q4: '.$Q4.'
|---------END MESSAGE----------|';
mail($to, $mailsubject, $body, $header);
if ($Q3 == "yes") {
header('Location: http://example.com/success.php');
} else {
header('Location: http://example.com/resources.php');
}
?>
Aucun commentaire:
Enregistrer un commentaire