Пример #1
0
 * @param [Array] $fields_req a map of field name to required
 */
function setMessageBody($fields_req)
{
    $message_body = "";
    foreach ($fields_req as $name => $required) {
        $postedValue = $_POST[$name];
        if ($required && empty($postedValue)) {
            errorResponse("{$name} is empty.");
        } else {
            $message_body .= ucfirst($name) . ":  " . $postedValue . "\n";
        }
    }
    return $message_body;
}
$email = $_POST['email'];
header('Content-type: application/json');
//do some simple validation. this should have been validated on the client-side also
if (empty($email)) {
    errorResponse('Email or message is empty.');
}
$messageBody = setMessageBody($fields_req);
// if the url field is empty
if (isset($_POST['url']) && $_POST['url'] == '') {
    // then send the form to your email
    mail('*****@*****.**', 'Contact Form', print_r($_POST, true));
}
// otherwise, let the spammer think that they got their message through
//try to send the message
echo json_encode(array('message' => 'Your message was successfully submitted.'));
mail(MY_EMAIL, EMAIL_SUBJECT, $messageBody, "From: {$email}");
Пример #2
0
 *
 * @param [Array] $fields_req a map of field name to required
 */
function setMessageBody($fields_req)
{
    $message_body = "";
    foreach ($fields_req as $name => $required) {
        if ($required && empty($name)) {
            errorResponse("{$name} is empty.");
        } else {
            $message_body .= ucfirst($name) . ":  " . $_POST[$name] . "\n";
        }
    }
    return $message_body;
}
$email = $_POST['email'];
header('Content-type: application/json');
//do some simple validation. this should have been validated on the client-side also
if (empty($email)) {
    errorResponse('Email or message is empty.');
}
//do Captcha check, make sure the submitter is not a robot:)...
include_once './vender/securimage/securimage.php';
$securimage = new Securimage();
if (!$securimage->check($_POST['captcha_code'])) {
    errorResponse('Invalid Security Code');
}
//try to send the message
echo json_encode(array('message' => 'Your message was successfully submitted.'));
mail(MY_EMAIL, EMAIL_SUBJECT, setMessageBody($fields_req), "From: {$email}");
Пример #3
0
 * Comment: <message/comment submitted by user>
 *
 * @param String $name     name of submitter
 * @param String $message message/comment submitted
 */
function setMessageBody($name, $message)
{
    $message_body = "Name: " . $name . "\n\n";
    $message_body .= "Comment:\n" . nl2br($message);
    return $message_body;
}
$email = $_POST['email'];
$message = $_POST['message'];
header('Content-type: application/json');
//do some simple validation. this should have been validated on the client-side also
if (empty($email) || empty($message)) {
    errorResponse('Email or message is empty.');
}
//do Captcha check, make sure the submitter is not a robot:)...
include_once './vender/securimage/securimage.php';
$securimage = new Securimage();
if (!$securimage->check($_POST['captcha_code'])) {
    errorResponse('Invalid Security Code');
}
//try to send the message
if (mail(MY_EMAIL, "Newspective Contact", setMessageBody($_POST["name"], $message), "From: {$email}")) {
    echo json_encode(array('message' => 'Your message was successfully submitted.'));
} else {
    header('HTTP/1.1 500 Internal Server Error');
    echo json_encode(array('message' => 'Unexpected error while attempting to send e-mail.'));
}
Пример #4
0
 * Comment: <message/comment submitted by user>
 *
 * @param String $name     name of submitter
 * @param String $message message/comment submitted
 */
function setMessageBody($name, $message)
{
    $message_body = "Name: " . $name . "\n\n";
    $message_body .= "Comment:\n" . nl2br($message);
    return $message_body;
}
$email = $_POST['email'];
$message = $_POST['message'];
header('Content-type: application/json');
//do some simple validation. this should have been validated on the client-side also
if (empty($email) || empty($message)) {
    errorResponse('Email or message is empty.');
}
//do Captcha check, make sure the submitter is not a robot:)...
include_once './securimage.php';
$securimage = new Securimage();
if (!$securimage->check($_POST['captcha_code'])) {
    errorResponse('Invalid Security Code');
}
//try to send the message
if (mail(MY_EMAIL, "Feedback Form Results", setMessageBody($_POST["name"], $message), "From: {$email}")) {
    echo json_encode(array('message' => 'Your message was successfully submitted.'));
} else {
    header('HTTP/1.1 500 Internal Server Error');
    echo json_encode(array('message' => 'Unexpected error while attempting to send e-mail.'));
}