<?php
// Mail sending script - AGRT 8/7/2016 (after TheWebHelp.com)

$target_email = "phyllis@phyllisfantasies.com";
$subj_prefix = "[Phyllis Fantasies Online Form]";
$contact_form = "contact.php";

$name = stripslashes($_POST["name"]);
$from = stripslashes($_POST["from"]);
$subject = stripslashes($_POST["subject"]);
$message = stripslashes($_POST["message"]);
$verif_box = trim($_POST["verif_box"]);

$cv = "VC:" . sha1($verif_box) . 'a4xn';
$cm = $_COOKIE['vericon'];
if ($cv == $cm) {
   mail($target_email, $subj_prefix . " " . $subject, 
        "Sent by: $name (" . $_SERVER['REMOTE_ADDR'] . ")\n\n" . $message,
	"From: $from");
   setcookie('vericon', '', 1, '/'); // destroy cookie value

   header('Location: index.html');
   exit;

} else if (isset($message) and ($message != "")) {
  $p = "name=" . urlencode($name) . "&from=" . urlencode($from) . "&subject=" . urlencode($subject);
  $p = $p . "&message=" . urlencode($message) . "&wrong_code=true";
  header("Location: " . $contact_form . "?" . $p);
  exit;

} else {
    echo "Error accessing mail page";
}
?>
