Add validation to the PHP, else even if no values was sent via POST, just by visiting the page its going to send a blank email. Most likely a search engine or such bot is just crawling.
So check its POST
<?php
if($_SERVER['REQUEST_METHOD']==='POST'){
//put code here
}
?>
and check your values are set min-max length ect
<?php
...
...
...
//Comments
if(empty($_POST['comments'])){
//comments empty, do or set something
}else if(strlen($_POST['comments']) < 5){
//not long enough, do or set something
}else if(strlen($_POST['comments']) > 50){
//too large, do or set something
}
?>
and most importantly check email is really an email..
<?php
if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
//is an email
}else{
//not an email
}
?>
Also your want to add a basic captcha else your be enjoying 1000s of marketing/spam emails per day.
Good luck, implementing it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…