I'm using PHPMailer to mail form data in an HTML form when the user submits the form. The syntax error comes when putting quotes around fullName in the body of the email. If there are no quotes, it doesn't show an error. I'm new to PHP and am not really sure how to reference an HTML form from within PHP, when I've declared that a set of code is HTML. Here is my code:
NOTE: I'm using Dreamweaver to code this and sometimes the syntax correction is incorrect, but I want to make sure before I go ignoring it and code my entire document.
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp1.example.com;smtp2.example.com";
$mail->SMTPAuth = true;
$mail->Username = 'smtpusername';
$mail->Password = 'smtppassword';
$mail->From="[email protected]";
$mail->FromName="My site's mailer";
$mail->Sender="[email protected]";
$mail->AddAddress("[email protected]");
$mail->Subject = "Test 1";
$mail->IsHTML(true);
$mail->Body = "
<h1>Graphics Request</h1>
Name: $_POST['fullName']<br />
";
$mail->AltBody="This is text only alternative body.";
if(!$mail->Send())
{
echo "Error sending: " . $mail->ErrorInfo;;
}
else
{
echo "Letter is sent";
}
?>
{}inside the double-quoted string as in{$_POST['fullName']}