2013-04-07 5 views
0

내 웹 사이트에 가득 찬 갑작스런 문의 양식이 1970 년 1 월 1 일부터받은 편지함으로 들어옵니다 ???PHP 연락처 양식의 날짜가 잘못되었습니다

그들은 내받은 편지함의 맨 아래에 끝나는하고 내가 몇 리드를 놓친 ...

이 갑자기 일어나고 시작하는 방법에 어떤 아이디어?

내 연락처 페이지에서 사용하고있는 코드는 다음과 같습니다 -

<?php 
if(isset($_POST['email'])) { 

// EDIT THE 2 LINES BELOW AS REQUIRED 
$email_to = "my email address"; 
$email_subject = "Website Contact Enquiry"; 


function died($error) { 
    // your error code can go here 
    echo "We are very sorry, but there were error(s) found with the form you submitted.  "; 
    echo "These errors appear below.<br /><br />"; 
    echo $error."<br /><br />"; 
    echo "Please go back and fix these errors.<br /><br />"; 
    die(); 
} 

// validation expected data exists 
if(!isset($_POST['name']) || 
    !isset($_POST['email']) || 
    !isset($_POST['tel']) || 
    !isset($_POST['message'])|| 
    !isset($_POST['formtype']) 
    ) { 
    died('We are sorry, but there appears to be a problem with the form you submitted.');  
} 

$name = $_POST['name']; // required 
$email_from = $_POST['email']; // required 
$tel = $_POST['tel']; // required 
$message = $_POST['message']; // required 
$formtype = $_POST['formtype']; 


$email_message = "Form details below.\n\n"; 

function clean_string($string) { 
    $bad = array("content-type","bcc:","to:","cc:","href"); 
    return str_replace($bad,"",$string); 
} 

$email_message .= "Name: ".clean_string($name)."\n"; 
$email_message .= "Email: ".clean_string($email_from)."\n"; 
$email_message .= "Tel: ".clean_string($tel)."\n"; 
$email_message .= "Message: ".clean_string($message)."\n"; 
$email_message .= "formtype: ".clean_string($formtype)."\n"; 

// create email headers 
$headers = 'From: '.$email_from."\r\n". 
'Reply-To: '.$email_from."\r\n" . 
'X-Mailer: PHP/' . phpversion().date(); 
@mail($email_to, $email_subject, $email_message, $headers); 
?> 

답변

1

이 헤더에이 추가 :

'Date: ' . date('r'), 

는 또한, $email_from을 소독해야합니다. 지금은 스팸 발송자가 다른받는 사람에게 전자 메일을 보내고 머리글을 변경할 수 있도록 허용하고 있습니다. 여기에 더 읽기 : http://www.securephpwiki.com/index.php/Email_Injection

관련 문제