<?php if ( ! defined( 'ABSPATH' ) ) exit; if( isset($_POST) ){ $formok = true; $errors = array(); $ipaddress = $_SERVER['REMOTE_ADDR']; $date = date('d/m/Y'); $time = date('H:i:s'); $name = filter_var($_POST['name'], FILTER_SANITIZE_STRING); $email = filter_var($_POST['email'], FILTER_SANITIZE_STRING); $telephone = filter_var($_POST['telephone'], FILTER_SANITIZE_STRING); $enquiry = filter_var($_POST['enquiry'], FILTER_SANITIZE_STRING); $message = filter_var($_POST['message'], FILTER_SANITIZE_STRING); if(empty($name)){ $formok = false; $errors[] = "You have not entered a name"; } if(empty($email)){ $formok = false; $errors[] = "You have not entered an email address"; }elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){ $formok = false; $errors[] = "You have not entered a valid email address"; } if(empty($message)){ $formok = false; $errors[] = "You have not entered a message"; } elseif(strlen($message) < 20){ $formok = false; $errors[] = "Your message must be greater than 20 characters"; } if($formok){ $headers = "From: {$name} <{$email}> "."\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $emailbody = "<p>You have recieved a new support from Instagram Feed Plugin.</p> <p><strong>Name: </strong> {$name} </p> <p><strong>Email Address: </strong> {$email} </p> <p><strong>Telephone: </strong> {$telephone} </p> <p><strong>Enquiry: </strong> {$enquiry} </p> <p><strong>Message: </strong> {$message} </p> <p>This message was sent from the IP Address: {$ipaddress} on {$date} at {$time}</p>"; mail("arrowplugins@gmail.com","Instagram Feed Plugin Support",$emailbody,$headers); } $returndata = array( 'posted_form_data' => array( 'name' => $name, 'email' => $email, 'telephone' => $telephone, 'enquiry' => $enquiry, 'message' => $message ), 'form_ok' => $formok, 'errors' => $errors ); if(empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest'){ session_start(); $_SESSION['cf_returndata'] = $returndata; header('location: ' . $_SERVER['HTTP_REFERER']); } } 