Hi bradgrafelman,
Thank you very much for the advise 🙂
I see, so it sounds like where I'm going wrong it using FILTER_SANITIZE_STRING. Probably best I show the code I have just to ensure that I'm correctly doing it. Please see bits of my code below.
Prepared statement
$stmt = $dbc->prepare("INSERT INTO my_form(name, email, url, comment) VALUES (:name, :email, :url, :comment)");
$insert = array(
':name' => $name,
':email' => $email,
':url' => $url,
':comment' => $comment
);
$stmt->execute($insert);
Email which is sending HTML.
Only user inputted field which is in the header is $email. Guessing that should be ran through FILTER_SANITIZE_EMAIL ? Mainly just want to allow sing and double quotes and block out anything harmful such as any JavaScript they're trying to put into links etc.
$to = 'me@myemail.com';
$message = '
<html>
<body>
<p><strong>Name</strong><br />'. $name .'</p>
<p><strong>Email address</strong><br />'. $email .'</p>
<p><strong>Web address</strong><br />'. $url .'</p>
<p><strong>Comments</strong><br />'. $comment .'</p>
<body>
</html>
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: My Form <myform@myemail.com>' . "\r\n";
$headers .= 'Reply-To: '.$email. "\r\n" ;
$headers .= 'X-Mailer: PHP/' . phpversion();
$mail_sent = mail( $to, $subject, $message, $headers );