Background
Web contact form.
Problem
The $_POST array is empty. When errors are turned on, no errors were detected (except for empty array values). The code was tested and worked at some point, and then remained untouched until I posted this question. The host could update.
Software
- PHP 5.2.17
- Apache 2.0.63
- SSI
HTML form
The HTML form is as follows:
<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>
PHP code
When submitting the form, the following code is called:
$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"] ) );
entrance
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 ) `
file_get_contents('php://input') == Empty
Questions
- What could cause the PHP POST variable to be empty?
- Why does the
POST method translate to the GET method?
I think this is a php.ini or httpd.conf conflict, but it cannot be sure (this is a hosting domain).
Thanks.
Update
The following test is performed.
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>
test.php
<? echo $_POST["test"]; ?>
Decision
Removed the following line from the .htaccess file:
RewriteRule ^(.*)$ http://www.whitemagicsoftware.com/$1 [R=301,L]