PHP安全电子邮件通知表

时间:2013-11-25 23:04:30

标签: php html email

我有以下代码,其中包含index.html和send_mail.php。我收到了电子邮件但没有在电子邮件的字段上捕获数据输入。任何建议

HTML
//
<form action="send_mail.php" method="post">
                <input type="text" onClick="this.value='';" onFocus="this.select()" onBlur="this.value=!this.value?'Email Address':this.value;" value="Email Address"/>
              <input type="submit" name="email_address" value="Notify Me"/>

            </form>

PHP

<?php
/*

$webmaster_email = "myemail@myemail.com";


$splah_page = "index.html";
$error_page = "error_message.html";
$thankyou_page = "thank_you.html";
$email_address = $_POST['email_address'] ;

function isInjected($str) {
    $injections = array('(\n+)',
    '(\r+)',
    '(\t+)',
    '(%0A+)',
    '(%0D+)',
    '(%08+)',
    '(%09+)'
    );
    $inject = join('|', $injections);
    $inject = "/$inject/i";
    if(preg_match($inject,$str)) {
        return true;
    }
    else {
        return false;
    }
}
if (!isset($_REQUEST['email_address'])) {
header( "Location: $index_page" );
}


elseif (empty($email_address) ) {
header( "Location: $error_page" );
}

if (!isset($_REQUEST['email_address'])) {
header( "Location: $splash_page" );
}


elseif (empty($email_address) ) {
header( "Location: $error_page" );
}

elseif ( isInjected($email_address) ) {
header( "Location: $error_page" );
}


else {
mail( "$webmaster_email", "Keep Me Posted",

 "From: $email_address" );
header( "Location: $thankyou_page" );
}
?>
?>

//我正在疯狂地试图解决这个问题。

0 个答案:

没有答案