I am trying to have a form with 2 steps. I want to have the info from form 1 send to an email even when the user did not complete the 2nd form. 2nd form is posting other info and will take the user to thank you page when completed.I have the below script. It takes me to the 2nd form, there is no error message but it is not sending the email to me.
[CODE]<?php
session_start();
require_once(“class.phpmailer.php”);
$errors = array();
if (‘POST’ === $_SERVER[‘REQUEST_METHOD’])
{
$salutation = sanitize($_POST[‘salutation’]);
$fname = sanitize($_POST[‘fname’]);
$lname = sanitize($_POST[‘lname’]);
$email = sanitize($_POST[’email’]);
if (empty($fname))
{
$errors[‘fname’] = “First’s name cannot be empty.”;
}
if (empty($lname))
{
$errors[‘lname’] = “last’s name cannot be empty.”;
}
if (count($errors) === 0)
{
include(“config.php”);
$message = ‘
Name: ‘.salutation.’ ‘.$fname.’ ‘.$lname.’
Email: ‘.$email.'<br>
‘;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = ‘ssl’;
$mail->Host = $host;
$mail->Port = $port;
$mail->Username = $User;
$mail->Password = $PWD;
$mail->SetFrom($email, $fname . ” ” . $lname);
$mail->AddAddress(’[email protected]’);
$mail->Subject =’Test’;
$mail->Body = $message;
$mail->WordWrap = 50;
$mail->isHTML(true);
$mail->Send();
exit(header(“Location:page2.php”));
}}
function sanitize($value)
{
return trim(strip_tags($value));
}
?>