<?php

////////////function Email/////////////////

session_start();

function yourname() {
    global $error;
    if (!$_POST['txtname']) {
        $error.="you forgot your name";
        echo '<span style="color:#FF0000;">*</span>';
    }
}

function email() {
    global $error;
    $format_email = "^[0-9A-Z\.\_\-]+@[A-Z\_]+\.[A-Z\.]{2,7}$";
    $email = $_POST['txtemailaddress'];
    if ($_POST['txtemailaddress'] != "") {
        if (!(eregi($format_email, $_POST['txtemailaddress']))) {
            $error.="Sorry not correct";
            echo '<span style="color:#FF0000;">_@_._</span>';
        }
    } else {
        $error.="Sorry not correct";
        echo '<span style="color:#FF0000;">_@_._</span>';
    }
}

function subject() {
    global $error;
    if (!($_POST['txtsubject'])) {
        $error.='No Subject';
        echo '<span style="color:#FF0000;">*</span>';
    }
}

////////////function Email/////////////////
include("contact.html");
?>
<?php

if (isset($_POST['btnsubmit'])) {
    $_SESSION['x'] = $_POST['txtname'];
    $_SESSION['y'] = $_POST['txtemailaddress'];
    $_SESSION['z'] = $_POST['txtsubject'];
    $_SESSION['a'] = $_POST['freeRTE_content'];
    if ($error == "") {
        $x = $_POST['txtname'];
        $y = $_POST['txtemailaddress'];
        $z = $_POST['txtsubject'];
        $a = $_POST['freeRTE_content'];
        mail("support@khemarasoft.com", $z, $a, "From:" . $y . "\r\nReply-to:" . $y . "\r\nContent-type: text/html; charset=us-ascii");
        $_SESSION['oksend'] = 'sendok';
    }
    else{
        echo "<script>alert('The message Could not Send!')</script>";
    }
    if ($_SESSION['oksend'] == 'sendok') {
        echo "<script>alert('The message Send Successful')</script>";
        unset($_SESSION['x']);
        unset($_SESSION['y']);
        unset($_SESSION['z']);
        unset($_SESSION['a']);
        unset($_SESSION['oksend']);
    }
}
unset($_SESSION['oksend']);
?>