Validate a form field with PHP (ServerSide)

For security reasons I’ve added a security input/question into my form.

Something like:

"Please type the word ‘puppy’ into the space below:
____________"

I was able to get help validating it in JavaScript, but I realized I also need it validated with php incase javascript is disabled.

Can someone help me work that into my exhisting php code?


<?php
if(isset($_POST['submit'])) {

    $subject = "Contact Message From XXXXX.com";
    $from = 'From: ' . $_POST["name"] . "
";
    $to = "adam@XXXXX.com";
    
	$message = "CONTACT MESSAGE FROM XXXXX.COM" . "


"; 
    $message .= "Name:
" . $_POST["name"] . "

";
	$message .= "Email:
" . $_POST["email"] ."

";
	$message .= "Comments:
". $_POST["comments"];

    mail($to, $subject, $message, $from);
    
}
?> 

Thanks!


<?php 
if(isset($_POST['submit'])) { 
    $securityword = "puppy"
    $validatefield= $_POST['validate'];
    $subject = "Contact Message From XXXXX.com"; 
    $from = 'From: ' . $_POST["name"] . "
"; 
    $to = "adam@XXXXX.com"; 
     
    $message = "CONTACT MESSAGE FROM XXXXX.COM" . "


";  
    $message .= "Name:
" . $_POST["name"] . "

"; 
    $message .= "Email:
" . $_POST["email"] ."

"; 
    $message .= "Comments:
". $_POST["comments"]; 
    
    if($validatefield == $securityword) {
    mail($to, $subject, $message, $from); 
    }else{
	echo "Validation Failed";
	}
} 
?> 

Been a while since I used php, you might wanna check that