2011-10-03 9 views
0

POST로 데이터를 보내려고하지만 var_dump 함수를 호출하면 결과는 array(0)입니다.

AJAX로 post 메소드를 사용하는 다른 양식은 변수의 올바른 값을 결과로 가져오고 HTML은 작동하지 않습니다.

왜 이런 일이 일어날 수 있습니까?

형태 :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     <html xmlns="http://www.w3.org/1999/xhtml"> 
     <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
     <title>Untitled Document</title> 
     </head> 

     <body> 
     <form target="_new" enctype='application/x-www-form-urlencoded' action="include/php/produtos/romaneio/prueba.php" method="post"> 
     <input type="text" value="12" id="a" /> 
     <input type="submit" /> 
     </form> 
     </body> 
     </html> 

PHP는 다음 요소를 사용하여 명명 name= 경우 폼 요소

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
    <title>Untitled Document</title> 
    </head> 

    <body> 
    <? var_dump($_POST); 
    ?> 
    </body> 
    </html> 
+1

왜 VAR 덤핑'$ GLOBALS'을 당신에게 있습니다합니다 (id 속성은 다른 것들에 대해 말하자면, 자바 스크립트 나 CSS, 통해 DOM 작업에 국한입니다.)? 디버그 목적으로'$ _POST' (또는 적어도 $ _REQUEST)를 var-dumping해야합니다. 등록 글로벌을 활성화하지 않은 한 (** ** ** ** ** **에 대한 조언 **). –

+0

@ 브래드 : 나는 여기에'$ GLOBALS'를 추천 할 것입니다. 왜냐하면 적어도 JIT 초기화되어 있기 때문입니다. 그러나 레지스터 전역 변수는 아무 관계가 없습니다. [$ GLOBALS]에는 '$ _POST'가 포함되어 있습니다.] (http://codepad.org/9Tj25yeq). –

+1

@ TomalakGeret'kal : 어떤 시나리오에서든 사람들이'$ GLOBALS'을 사용하는 것을 보았을 때 동의했습니다. : shrug : –

답변

3

값은 $_POST에 추가 될 것이다. 따라서 id="d" 대신 name="d"을 추가하십시오.

+0

답변 해 주셔서 감사합니다 – ricbecen

3

inputname으로 보내지 않았습니다. 이 양식에는 제출할 수있는 콘텐츠가 없습니다.

<form target="_new" enctype='application/x-www-form-urlencoded' action="include/php/produtos/romaneio/prueba.php" method="post"> 
    <input type="text" value="12" name="a" /> 
    <input type="submit" /> 
</form>