2014-07-25 21:44:57 +00:00
< ? php
2017-06-13 00:13:02 +00:00
$email_address = filter_var ( $_POST [ 'email' ], FILTER_VALIDATE_EMAIL );
2014-07-25 21:44:57 +00:00
// Check for empty fields
if ( empty ( $_POST [ 'name' ]) ||
empty ( $_POST [ 'email' ]) ||
empty ( $_POST [ 'phone' ]) ||
empty ( $_POST [ 'message' ]) ||
2017-06-13 00:13:02 +00:00
! $email_address )
2014-07-25 21:44:57 +00:00
{
echo " No arguments Provided! " ;
return false ;
}
$name = $_POST [ 'name' ];
2017-06-13 00:13:02 +00:00
if ( $email_address === FALSE ) {
2015-01-30 08:42:13 +00:00
echo 'Invalid email' ;
exit ( 1 );
}
2014-07-25 21:44:57 +00:00
$phone = $_POST [ 'phone' ];
$message = $_POST [ 'message' ];
2019-11-26 14:36:53 +00:00
if ( empty ( $_POST [ '_gotcha' ])) { // If hidden field was filled out (by spambots) don't send!
// Create the email and send the message
2023-04-02 22:19:07 +00:00
$to = 'adil@asadqi.com' ; // Add your email address inbetween the '' replacing adil@asadqi.com - This is where the form will send a message to.
2019-11-26 14:36:53 +00:00
$email_subject = " Website Contact Form: $name " ;
$email_body = " You have received a new message from your website contact form. \n \n " . " Here are the details: \n \n Name: $name\n\nEmail : $email_address\n\nPhone : $phone\n\nMessage : \n $message " ;
2023-04-02 22:19:07 +00:00
$headers = " From: adil@asadqi.com \n " ; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
2019-11-26 14:36:53 +00:00
$headers .= " Reply-To: $email_address " ;
mail ( $to , $email_subject , $email_body , $headers );
return true ;
}
echo " Gotcha, spambot! " ;
return false ;
2015-01-28 21:47:26 +00:00
?>