<?php
session_start();

$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET") {
        $query_vars = $_GET;
}
elseif ($request_method == "POST") {
        $query_vars = $_POST;
}


//if (!isset($MMcode) || strtolower($MMcode) != 'br549')
	//die('Captcha Problem - Colby');
if(isset($_POST["captcha"])&&!empty($_POST["captcha"])&&$_SESSION["code"]==$_POST["captcha"])
{
echo "Correct Code Entered";
}
else
{
die("Wrong Code Entered");
}

reset($query_vars);
function customsort($a,$b) {
        // $a is array for form vars, $b is comma seperated case sensitive field order
        // this is case sensitive -- good idea to hrc that.
        $data = array();
        if ( strstr($b,',') == FALSE )  {
                $b = $b.",";
        }
        $ordering = split(',',$b);
        foreach ($ordering as $orderitem) {
                if ( ($orderitem != null) && ($orderitem != "") ) {
                        if (isset($a[$orderitem])) {
                                $data[$orderitem] = $a[$orderitem];
                        }
                }
        }
        foreach ($a as $key=>$val) {
                $data[$key] = $a[$key];
        }
        return $data;
}

function xmlentities($string) {
        return str_replace ( array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $string);
}

$t = date("U");



reset($query_vars);
$message = "<html><body>";        
$message .= "<table border=\"1\" cellspacing=\"1\" cellpadding=\"2\">\n";

reset($query_vars);
while (list ($key, $val) = each ($query_vars)) {
        if ($key == "redirect") {
                $landing_page = $val;
        }
        if ( ($key == "form_order") ||
                ($key == "form_format") ||
                ($key == "form_delivery") ||
                ($key == "redirect") ) {

        }
        else {
                
			$message .= "\t<tr>\n";
			$message .= "\t\t<td><b>$key</b></td>\n";
			$message .= "\t\t<td>$val</td>\n";
			$message .= "\t</tr>\n";
                       
        }
}


$message .= "</table>\n";
$message .= "</body></html>\n";

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: 'info@marcomaids.com>\r\n" ."X-Mailer: php \r\n";

mail($query_vars["To"],$query_vars["Subject"], $message, $headers);

if ($landing_page != "") {
        header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
}
else {
        header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}


?>

