Hi guys
Hoping you can help me with this. I'm very much a front end person, I know HTML, CSS and some JS but when it comes to PHP and very much a newbie.
I'm using this code to process a straight forward contact form. I'm using the PHP Mailer as I need to use an external smtp server and the company I use for this provided some basic code.
Its working but I'm getting a error flash up before I see the success page that says "Undefined variable: message in send.php on line 25.
Why is this happening and how do I fix it?
Thanks guys.
my code
<?php
require("PHPMailerAutoload.php"); // path to the PHPMailer class.
$after = "/contact/thanks.php";
$oops = "/contact/error.php";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->Host = "smtpcorp.com";
$mail->Port = "2525";
$mail->SMTPAuth = true;
$mail->Username = "name@hotmail.com";
$mail->Password = "xxx";
$mail->From = "name@hotmail.com";
$mail->FromName = "Richard Dale";
$mail->AddAddress("name@hotmail.com", "Rachel Recipient");
$mail->AddReplyTo("name@hotmail.com", "Sender's Name");
$mail->Subject = "Contact enquiry from the website";
$message .= "How can we help: {$_POST['help']} \n\n";
$message .= "Name: {$_POST['name']} \n\n";
$message .= "Email: {$_POST['email']} \n\n";
$message .= "Telephone: {$_POST['tel']} \n\n";
$message .= "Message: {$_POST['message']} \n\n";
$message .= "Address: {$_POST['address']} \n\n";
$mail->Body = $message;
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$oops\">";
} else {
echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$after\">";
}
?>