基于Web的联系表单.
该$_POST数组为空.启用错误时,未找到任何错误(空数组值除外).代码经过测试并在一个点上工作,然后保持不变,直到我发布了这个问题.主机可能已执行升级.
HTML表单如下:
<form method="post" action="contact.php" id="commentForm">
<label for="name">Name</label>
<input type="text" name="name" id="name" maxlength="64" /><br />
<label for="email">Email</label>
<input type="text" name="email" id="email" maxlength="320" /><br />
<label for="message">Message</label>
<textarea name="message" rows="10" cols="40" id="Message"></textarea><br />
<label for="human">40 + 2 =</label>
<input type="text" name="human" id="human" size="10" maxlength="3" /><br />
<p align="center">
<input type="submit" name="submit" value="Send" class="submit-button" />
</p>
</form>
Run Code Online (Sandbox Code Playgroud)
提交表单时调用以下代码:
$reason = 'default';
error_reporting( 0 );
ini_set( 'display_errors', 0 );
ini_set( 'register_globals', 0 );
ini_set( 'allow_url_fopen', 0 );
ini_set( 'expose_php', 0 );
ini_set( 'magic_quotes_gpc', 0 );
function not_contacted() {
global $reason;
// Redirects to computer, name, email, or message.
//
header( 'Location: ../error-'.$reason.'.shtml' );
}
function wms_error_handler($errno, $errstr, $errfile, $errline) {
not_contacted();
return true;
}
function wms_shutdown() {
if( is_null( $e = error_get_last() ) === false ) {
not_contacted();
}
}
set_error_handler( "wms_error_handler" );
register_shutdown_function( 'wms_shutdown' );
$name = trim( stripslashes( $_POST["name"] ) );
Run Code Online (Sandbox Code Playgroud)
echo $_SERVER["REQUEST_METHOD"]; == GET
print_r( $_GET ); == Array ( )
print_r( $_POST ); == Array ( )
print_r( $_REQUEST ); ==
Array ( [__utma] => 181723617.1357984856.1311884601.1313715852.1313720411.12 [__utmz] => 181723617.1313720411.12.10.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=jigo [__utmc] => 181723617 [__utmb] => 181723617.3.10.1313720411 ) `
Run Code Online (Sandbox Code Playgroud)
file_get_contents('php://input') ==空
POST方法被变换为GET方法?我认为这是一个php.ini或httpd.conf冲突,但不能确定(它是一个托管域).
谢谢.
以下测试有效.
test.shtml中
<html>
<body>
<form method="post" action="test.php">
<input type="hidden" name="test" value="test" />
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
test.php的
<?
echo $_POST["test"];
?>
Run Code Online (Sandbox Code Playgroud)
从.htaccess文件中删除了以下行:
RewriteRule ^(.*)$ http://www.whitemagicsoftware.com/$1 [R=301,L]
Run Code Online (Sandbox Code Playgroud)
从文件中删除以下行.htaccess:
RewriteRule ^(.*)$ http://www.whitemagicsoftware.com/$1 [R=301,L]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4739 次 |
| 最近记录: |