TestContact

<?php
/*
Plugin Name: DigitSix Simple Contact Form
Plugin URI: http://dbxdigital.com/
Description: Simple Contact Form Plugin by DBX Digital.
Version: 1.0.3
Author: Amit Kumar
Author URI: http://amitkumar.in
*/

function html_form_code() {
echo '’;
echo ‘

‘;
echo ‘Your Name (required)
‘;
echo ”;
echo ‘

‘;
echo ‘

‘;
echo ‘Your Email (required)
‘;
echo ”;
echo ‘

‘;
echo ‘

‘;
echo ‘Subject (required)
‘;
echo ”;
echo ‘

‘;
echo ‘

‘;
echo ‘Your Message (required)
‘;
echo ” . ( isset( $_POST[“cf-message”] ) ? esc_attr( $_POST[“cf-message”] ) : ” ) . ”;
echo ‘

‘;
echo ‘

‘;
echo ”;
}

function deliver_mail() {

// if the submit button is clicked, send the email
if ( isset( $_POST[‘cf-submitted’] ) ) {

// sanitize form values
$name = sanitize_text_field( $_POST[“cf-name”] );
$email = sanitize_email( $_POST[“cf-email”] );
$subject = sanitize_text_field( $_POST[“cf-subject”] );
$message = esc_textarea( $_POST[“cf-message”] );

// get the blog administrator’s email address
$to = get_option( ‘admin_email’ );

$headers = “From: $name ” . “rn”;

// If email has been process for sending, display a success message
if ( wp_mail( $to, $subject, $message, $headers ) ) {
echo ‘

‘;
echo ‘

Thanks for contacting us, we will be in touch as soon as possible.

‘;
echo ‘

‘;
} else {
echo ‘An unexpected error occurred’;
}
}
}

function cf_shortcode() {
ob_start();
deliver_mail();
html_form_code();

return ob_get_clean();
}

add_shortcode( ‘simple_contact_form’, ‘cf_shortcode’ );

?>