2013-04-03 4 views
0

SOLVED : 입력 필드에서 name 속성을 생략했습니다. 나는 간단한 html/php -form을 가지고있다. 그리고 그것을 제출합니다. $ _POST는 항상 비어 있습니다. 내가 get을 시도하면 GET은 항상 비어 있습니다. $ _REQUEST와 php : // input과 동일합니다. 나는 그 대가로 아무것도 얻지 못한다.

이 주제에 많은 게시물이 있지만 아직 내 문제의 해결책을 찾지 못했습니다. 나는 재 작성이나 리다이렉트가 없다. method_request는 POST입니다. id와의 충돌이 없습니다. php : // input도 비어 있습니다. REQUEST도 비어 있습니다. 나는 Suhosin.simulation을 켜 놓았다. 그것은 작동하지 않는다는 것을 의미한다. POST_MAX_SIZE = 16M. 두 개의 작은 텍스트에 충분해야합니다.

php.ini 변수 request_order와 variable_order는 각각 GP와 GPS입니다. Magic_quotes_gpc가 꺼져 있습니다. 기본 mime-type = text/html이고 모든 페이지에는 charset UTF-8이 있습니다. php_sapi_name() 함수의 결과는 apache2handler입니다.

PHP 버전 = 5.3, 수호신 - 패치 0.9.1. OS = 우분투 12.04 LTS, 아파치 = 2.2.22.

다음은 두 파일입니다. 나는 그 (것)들을 조금 간단하게했다, 그러나 일반적으로 어떤 문제도없이 일하지 않는다. 나는 GET 방법과 비슷한 파일을 가지고있다.

<?php 

$tmpHeader = "<!DOCTYPE html><html><head>\n"; 
$tmpHeader .= "<meta charset=\"UTF-8\"> <meta http-equiv=\"Content-Type\" content=\"application/x-www-form-urlencoded; charset=utf-8\">\n"; 
$tmpHeader.= "<title>testPost</title>\n"; 
$tmpHeader.= "<link rel=\"stylesheet\" href=\"/css/layout.css\">\n"; 
$tmpHeader.= "<link rel=\"stylesheet\" href=\"/css/semantics.css\">\n"; 
$tmpHeader.= "<link rel=\"stylesheet\" href=\"/css/defaults.css\">\n"; 
$tmpHeader.="</head>"; 

$tmpBody = "<body id=\"defaultBody\"><section id=\"page\">\n"; 
$tmpBody .= "<div id=\"container\">\n"; 
$tmpBody .= "<form id=\"pagewrap\" name=\"pagewrap\" method=\"POST\" action=\"http://www.thuis.lb/testPost_2.php\" enctype=\"application/x-www-form-urlencoded\">\n"; 
$tmpBody .= "<input type=\"hidden\" id=\"context_id\" value=\"testPost\">\n"; 
$tmpBody.="<header id=\"pageHeader\">\n"; 
$tmpBody.="<div id=\"leftHeader\"><img src=\"".clientSideImages."Homerus.jpg\" alt=\"homerus\"></div>\n"; 
$tmpBody.="<div id=\"centralHeader\"><h1>Slogan</h1></div>\n"; 
$tmpBody.="</header>\n"; 

$pageData = "<section id=\"doc_content\">\n"; 
$pageData.= "<fieldset><legend>testPost</legend>\n"; 
$pageData.= "<div class=\"fourcolumns_odd\"><label for=\"username\">username</label></div>\n"; 
$pageData.= "<div class=\"fourcolumns_even\"><input type=\"text\" id=\"username\" value=\"\"></div>\n"; 
$pageData.= "<div class=\"fourcolumns_odd\"><label for=\"password\">password</label></div>\n"; 
$pageData.= "<div class=\"fourcolumns_even\"><input type=\"text\" id=\"password\" value=\"\"></div>\n"; 
$pageData.= "<div class=\"onecolumn\"><input type=\"submit\" id=\"submitButton\" value=\"inloggen\"></div>\n"; 
$pageData.= "</fieldset>\n"; 
$pageData.= "<input type=\"hidden\" id=\"passwordHash\" value=\"\">\n"; 
$pageData.="</section><!--end of section doc_content -->\n"; 
$tmpBody .= "<div id=\"leftWing\"><img src=\"".clientSideImages."IronPillarDelphi.jpg\" alt=\"homerus\"></div>\n"; 
$tmpBody.= "<div id=\"centerField\" class=\"centerVertically\">".$pageData."</div>\n"; 
$tmpBody.= "<div id=\"rightWing\"><img src=\"".clientSideImages."IronPillarDelphi.jpg\" alt=\"homerus\"></div>\n"; 
$tmpBody.="</form>\n"; 
$tmpBody.= "</div><!-- end of container -->\n"; 
$tmpBody.="</section><!-- end of page -->\n"; 
$tmpBody.="</body></html>\n"; 

logStatement('requestheaders: '); 
$testpostdata = file_get_contents("php://input"); 
log_r($testpostdata); 

print $tmpHeader.$tmpBody; 
?> 

다른 파일은 어느 $ _POST 데이터를 전송해야합니다 :

<!DOCTYPE html><html><head> 
<meta charset="UTF-8"> <meta http-equiv="Content-Type" content="application/x-www-form-urlencoded; charset=utf-8"> 
<title>testPost_II</title> 
<link rel="stylesheet" href="/css/layout.css"> 
<link rel="stylesheet" href="/css/semantics.css"> 
<link rel="stylesheet" href="/css/defaults.css"> 
</head><body id="defaultBody"><section id="page"> 
<div id="container"> 
<form id="pagewrap" name="pagewrap" method="POST" action="http://www.thuis.lb/testPost.php" enctype="application/x-www-form-urlencoded"> 
<header id="pageHeader"> 
<div id="leftHeader"><img src="/images/Homerus.jpg" alt="homerus"></div> 
<div id="centralHeader"><h1>Slogan</h1><span>Special for ><?php print getValue('username','nothing found');?></span></div> 
</header> 
<div id="leftWing"><img src="/images/IronPillarDelphi.jpg" alt="homerus"></div> 
<div id="centerField" class="centerVertically"><section id="doc_content"> 
<input type="text" id="context_id" value="<?php var_dump($_POST);?>"> 
<fieldset><legend>testPost_2</legend> 
<div class="fourcolumns_odd"><label for="username">username</label></div> 
<div class="fourcolumns_even"><input type="text" id="username" value="<?php print  getValue('username','Noname');?>"></div> 
<div class="fourcolumns_odd"><label for="password">password</label></div> 
<div class="fourcolumns_even"><input type="text" id="password" value="<?php echo getValue('password','Secret');?>"></div> 
<div class="fourcolumns_odd"><label for="request_method">request method</label></div> 
<div class="fourcolumns_even"><input type="text" id="username" value="<?php print $_SERVER['REQUEST_METHOD'];?>"></div> 
<div class="onecolumn"><input type="submit" id="submitButton" value="inloggen"></div> 
</fieldset> 
</section><!--end of section doc_content --> 
</div> 
<div id="rightWing"><img src="/images/IronPillarDelphi.jpg" alt="homerus"></div> 
</form> 
</div><!-- end of container --> 
</section><!-- end of page --> 
</body></html> 

www.thuis.lb는 로컬 서버의 이름입니다. IP 127.0.0.1입니다. Thuis는 집에서 네덜란드 인입니다. 내가 잊어 버렸거나 잘못하고있는 것이 있습니까?

EDIT : 몇 가지 추가 정보 더 복잡한 첫 번째 PHP에는 데이터베이스와의 정보 교환이 있습니다. 그것은 매력처럼 작동합니다. 전혀 문제 없습니다. 그 때문에이 문제는 보안 문제라고 생각합니까? www.thuis.lb에 가상 호스트 파일을 추가하겠습니다. 거의 기본 가상 호스트와 비슷하지만 문제가 될 수 있습니다.

<VirtualHost thuis.lb:80> 
    ServerName www.thuis.lb 
    ServerAlias thuis.lb *.thuis.lb 
    ServerAdmin [email protected] 
    DocumentRoot /var/www/thuis 
    RewriteEngine On 
    RewriteOptions Inherit 

<Directory /var/www/thuis/> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Order allow,deny 
    allow from all 
</Directory> 

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
<Directory "/usr/lib/cgi-bin"> 
    AllowOverride None 
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
    Order allow,deny 
    Allow from all 
</Directory> 

ErrorLog /var/log/apache2/thuis/error.log 

# Possible values include: debug, info, notice, warn, error, crit, 
# alert, emerg. 
LogLevel debug 

CustomLog /var/log/apache2/thuis/access.log combined 

Alias /doc/ "/usr/share/doc/" 
<Directory "/usr/share/doc/"> 
    Options Indexes MultiViews FollowSymLinks 
    AllowOverride None 
    Order deny,allow 
    Deny from all 
    Allow from 127.0.0.0/255.0.0.0 ::1/128 
</Directory> 
</VirtualHost> 

EDIT II : 추가 정보를 추가 할 수 있습니다. 액세스 로그에는 다음 줄이 있습니다. 127.0.0.1 - - [04/Apr/2013 : 11 : 13 : 43 +0200] "POST /testPost_2.php HTTP/1.1"200 2020 "http://www.thuis.lb/testPost.php" "Mozilla/5.0 (X11, 우분투, 리눅스 x86_64, rv : 19.0) 게코/20100101 파이어 폭스/19.0 ". 그것은 apache2가 좋은 순서로 게시물을 수신하고 있음을 보여줍니다. PHP에서 $ _POST는 여전히 완전히 비어 있습니다. Firebug> Net> Headers의 디스플레이에서 내용 길이는 0입니다.

+1

양식 필드 위의 두 번째 예와 값을 반환한다 게시물에 더 이름 때문에 아무것도 –

답변

1

모든 양식 입력란에 이름 속성 또는 id 속성이 있습니까? 각 입력 필드에 이름 속성을 추가하는 것만 큼 간단 할 수도 있습니다.

<input type="text" id="afield" value="a value"> 

는 동일하지

<input type="text" id="afield" name="afield" value="a value"> 

$ _POST [ '멀리'] 단

+0

와우, 정말 간단합니다! 대단히 감사합니다. 1 주일 동안 그것을 놓쳤습니다. –

관련 문제