2013-08-18 5 views
0

나는 간단한 이메일 연락을 받는다. 나는 제출할 때 이메일을 보낸다. 전자 메일이 전송되었지만 전자 메일에 양식 값이 없습니다 (이름 : 비어 있음, ...).

연락처 스크립트가 작동하지 않는 이유는 무엇입니까? 태그 enctype에 대한

<?php 
    if ($action == "send") //isset wyslij 
    { 
     if (!$_POST[name] || !$_POST[email] || !$_POST[phone] || !$_POST[enquiry]) 
     { 
      $problem = TRUE; 
      echo("<p>You have to fill all form.</p>"); 
     }  

     if (! $problem) 
     { 
      $data = date("d.m.y"); 
      $message = " 
       <p>Name: $_POST[name]</p> 
       <p>Phone: $_POST[phone]</p> 
       <p>Email: $_POST[email]</p> 
       <br> 
       <p>Enquiry: $_POST[enquiry]</p>"; 
      $od = "[email protected]"; 
      $content = $message; 

      $header = "From: $od \r\n"; 
      $header .= 'MIME-Version: 1.0' . "\r\n"; 
      $header .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; 

      (mail('[email protected]', 'New message from website', $content, $header)); 

      echo("<br><p>Message has been sent.</p>"); 
     } 
     else 
     { 
      echo("<p>Try <a href=contact.php>again</a></p>"); 
     } 
    } 
?> 
<form action="contact.php?action=send" method="post" enctype="text/plain"> 
    <label for="name">Name</label><input type="text" name="name" /></br></br> 
    <label for="email">Email</label><input type="text" name="email" /></br></br> 
    <label for="phone">Phone</label><input type="text" name="phone" /></br></br> 
    <label for="enquiry">Enquiry</label><textarea name="enquiry" cols="20" rows="10"></textarea></br></br> 
    <input type="submit" id="contact_button" value="Send" /> 
</form> 
+0

qoute 안에 배열 값이없는 것을 시도하십시오 : "

이름 :". $ _POST [이름]. "

"; –

답변

2

유효한 값은 다음과 같습니다

application/x-www-form-urlencoded 
multipart/form-data 

가 작동하지 않는 이유는 text/plain하고 그게 전부가있다.

+0

'text/plain' *은 * 유효한 값이지만 [http://www.w3.org/TR/html5/forms.html#text/plain-encoding-algorithm] : * 페이로드는 텍스트/일반 형식은 사람이 읽을 수 있어야합니다. 그들은 컴퓨터에서 신뢰할 수있는 해석이 가능하지 않습니다. * – Quentin

+0

"text/plain"은 HTML에는 유효하지만 PHP에는 해당되지 않습니다. 전송 된 데이터를 디코딩하지 않고'$ _POST'를 해당 enctype으로 채 웁니다. – Sven

0

HTML 양식 코드에서 "enctype"인수를 제거하고 다시 시도하십시오.