2017-01-07 1 views
-5

문제점이 있으며 문제가 무엇인지 알 수 없습니다. PHP 코드에서 게시물 요청에 포함 된 값을 읽을 수 없습니다.PHP에서 POST 값을 읽을 수 없습니다.

값을 읽는 것만으로 PHP 코드를 줄여도 응답으로 500 오류가 발생합니다.

POST 헤더를 검사했습니다 : 모든 데이터가 전송되므로 PHP로 액세스해야합니다. 여기

코드입니다 :

$('#contactForm').submit(function (e) { 

e.preventDefault(); 
var $form = $(this); 

// check if the input is valid 
if (!$form.valid()) return false; 



$.ajax({ 
    type: 'POST', 
    url: 'contact.php', 
    data: $('#contactForm').serialize(), 

    success: function (response) { 
     $(".formSuccess").show(); 
     $(".formError").hide(); 

    }, 
    error: function (response) { 
     $(".formSuccess").hide(); 
     $(".formError").show(); 

    } 
}); 

});

contact.php 

    <?php 
$empfaenger = "[email protected]"; 
$betreff = "Formularnachricht"; 
$text = "Formularnachricht: \n\n"; 
if(isset($_POST["name1"])) 
{ 
    $text .= "Name: ".&_POST["name1"]; 
} 
if(isset($_POST["email1"])) 
{ 
    $text .= "\n\nEmail: ".&_POST["email1"]; 
} 
if(isset($_POST["message1"])) 
{ 
    $text .= "\n\nNachricht: ".&_POST["message1"]; 
} 

//$text = wordwrap($text, 70); 
mail($empfaenger, $betreff, $text); 
?> 

도움 주셔서 감사합니다. :)

+2

$ _POST 대신 & _POST를 쓰십시오 .... – Lexib0y

+0

양식은 어디에 있습니까? –

+0

POST _header_를 검사하여 거기서 데이터를 본 경우 POST 데이터가 아닙니다. POST 데이터는 요청 _body_에 들어갑니다. –

답변

0

&_POST ->$_POST을 대체하십시오.

+0

고마워 ... 내가 보지 못했다니 믿을 수가 없어. – GidiLuke

관련 문제