我的表单中显示了重述,但当有人点击提交时,我只看到一个空白的白色屏幕。现在,我已经把有问题的php注释掉了,网站正常工作——你可以在www.necowindtest.com的注释选项卡下看到它。这是点击提交按钮时运行的php例程:注释部分之后的一切都正常工作。
<?php
// define variables and set to empty
$moniker = $commentdate = $comment = "";
//
//set timezone to mountian
date_default_timezone_set("America/Denver");
//
/*This starts the possibly problematic statements
//
// files placed in root of server
require_once "recapthchalib.php";
//
//exit for troubleshooting move this up if you didn't get a message or down if you did
exit("MADE IT THIS FAR");
//
//secret key
$secret = "6LfUTwoaAAAAAGIDFC8FqCoZX0TOTzSKFyOKT57h";
//
//empty response
$response = null;
//
//check secret key
$reCaptcha = new ReCaptcha($secret);
//
//if submitted check response
if ($_POST["g-recaptcha-response"]){
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
}
//
//display form or thank you for submission
if ($response != null && $response->success) {
echo "Hi " . $_POST["moniker"] . " thanks for the submission";
}
else {
echo "Sorry captcha verification was unsuccessful";
}
//
//This is the end of the problematic statements
//
*/
//load form fields into variables and check for extraneous characters
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$moniker = test_input($_POST["moniker"]);
$comment = test_input($_POST["comment"]);
}
//
function test_input($data) {
$data = trim($data); //trim out spaces
$data = stripslashes($data); //strip out slashes
$data = htmlspecialchars($data); //change special characters to entities
return $data;
}
//
//write comment to end of comment file (commenttest.txt)
$dateofcomm = date("m-d-Y");
$dateofcomm = $dateofcomm . " ";
$newline = "n";
$comment = $comment . " ";
$moniker = str_replace(" ", "", $moniker);
$newrecord = $dateofcomm . $comment . $moniker;
//
$prevcomm = fopen("commenttest.txt", "r") or die ("Unable to open file");
$allfiledcomments = file_get_contents("commenttest.txt");
file_put_contents("commenttest.txt", $dateofcomm);
file_put_contents("commenttest.txt", $comment, FILE_APPEND);
file_put_contents("commenttest.txt", $moniker, FILE_APPEND);
file_put_contents("commenttest.txt", $newline, FILE_APPEND);
file_put_contents("commenttest.txt", $allfiledcomments, FILE_APPEND);
fclose($prevcomm);
//
//display return link
echo "<div class='container' style='text-align: center'><br>";
echo "<a href='comments.php'><h2>Return to site</h2><br>";
echo "</div>";
//
//read comments from file (commenttest.txt)
$prevcomm = fopen("commenttest.txt", "r") or die ("Unable to open file");
while (!feof($prevcomm)) {
$acomm = fgets($prevcomm);
$acomm = chop($acomm);
$commdate = substr($acomm, 0, 10);
$bypos = strrpos($acomm, " ",); //get position of last space before name
$commenter = substr($acomm, $bypos,); //name is from last space to end
$bypos = $bypos - 10;
$filedcomm = substr($acomm, 11, $bypos); //comment is from position 11, after the date, to last space left to right
//
//write formatted comment to screen
echo "<div container style='font-size: 25px; border: solid red; border-radius: 20px;'><br>";
echo "<div container style='padding-left: 25px;'>";
echo $commdate;
echo "</div>";
echo "<div container style='padding-left: 50px; width: 225px; display: inline-block;'>";
echo "<h2><strong>COMMENT: </strong></h2>";
echo "</div><br>";
echo "<div container style='padding-left: 75px; width: 600px; display: inline-block;'>";
echo $filedcomm;
echo "</div><br>";
echo "<div container style='padding-left: 50px; width: 100px; display: inline-block;'>";
echo "<h2><strong>BY: </strong></h2>";
echo "</div>";
echo "<div container style='padding-left: 1px; width: 500px; display: inline-block;'>";
echo $commenter;
echo "</div>";
echo "</div><br>";
}
fclose($prevcomm);
?>
谢谢Alvaro,花了一段时间,但我发现了如何让bluehost显示php错误。现在我越来越近了。