// attach outer helper file
$mailFile = "mail.php";
if (file_exists("$mailFile"))
include("$mailFile");
// collect submitted data
$person = "";
$org = "";
$phone = "";
$mail = "";
$info = "";
if (isset($_POST['person'])) $person = HtmlChars($_POST['person']);
if (isset($_POST['org'])) $org = HtmlChars($_POST['org']);
if (isset($_POST['phone'])) $phone = HtmlChars($_POST['phone']);
if (isset($_POST['mail'])) $mail = HtmlChars($_POST['mail']);
if (isset($_POST['info'])) $info = HtmlChars($_POST['info']);
$errMsg = "";
$okMsg = "";
// if submit button clicked send email
if (isset($_POST['submit']))
{
if (ValidateData($errMsg))
{
PrepareAndSendEmail();
}
}
//--------------------------------------------------------
function ValidateData(&$errMsg)
{
global $person, $org, $phone, $mail, $info;
$valid = true;
if (trim($person) == "")
{
$errMsg .= "Enter 'Your Name'!
";
$valid = false;
}
if (trim($org) == "")
{
$errMsg .= "Enter 'Your company'!
";
$valid = false;
}
if (trim($phone) == "")
{
$errMsg .= "Enter 'Your telefon'!
";
$valid = false;
}
if (trim($mail) == "")
{
$errMsg .= "Enter 'E-mail'!
";
$valid = false;
}
return $valid;
}
//--------------------------------------------------------
function PrepareAndSendEmail()
{
global $person, $org, $phone, $mail, $info, $errMsg, $okMsg, $toEmail;
$subject = "E-mail";
$sendmessage = "E-MAIL \r\n
Name contact person: $person \r\n
Company: $org \r\n
Your telefon for contact: $phone \r\n
E-mail: $mail \r\n
Message: $info
";
$sendstatus = SendMail($sendmessage, $subject);
if($sendstatus == 1)
{
$okMsg = "
Message sent
" .
"Thank you, $person,Your message sent. " .
"***.
Error: Your message not sent
" .
"Please, repeat to send your message, " .
"use useally mail ($toEmail).
|