(首次发帖,抱歉,如果格式不好:()
我修补了一个html / php页面。它适用于我使用phpfiddle.org
的这个实时测试环境Working there it looks like this
当我保存代码并将文件上传到我的服务器时(我尝试了两台服务器,两者都有同样的问题),it's broken
我怀疑问题可能与标题有关,但我不知道。
这是我的代码:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
$potErr = $stackErr = "";
$pot = $stack = "";
$p = $s = $g1 = $g2 = $b11 = $b12 = $b21 = $b22 = $b23 = 0;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["pot"])) {
$potErr = "Pot size is required";
} else {
$pot = test_input($_POST["pot"]);
if (!preg_match("/^\d+$/",$pot)) {
$potErr = "Only integers allowed (might work with decimals though, I haven't tested it')";
}
}
if (empty($_POST["stack"])) {
$stackErr = "Stacksize is required";
} else {
$stack = test_input($_POST["stack"]);
if (!preg_match("/^\d+$/",$pot)) {
$stackErr = "Only integers allowed";
}
}
$p = $pot;
$s = $stack;
$g1 = pow(($p+2*$s)/$p,1/2);
$g2 = pow(($p+2*$s)/$p,1/3);
$b11 = ($p*$g1-$p)/2;
$b21 = ($p*$g2-$p)/2;
$b12 = $p*$g1*($g1-1)/2;
$b22 = $p*$g2*($g2-1)/2;
$b23 = $p*$g2*$g2*($g2-1)/2;
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<h2>Geometric Sizing Calculator</h2>
<p>
<i>Shoutout to AlexMartin's pokernerdz.com which is unfortunately offline. A quick geo calc in his honor! - Paul lnternet Otto </i>
</p>
<p><span class="error">* required field.</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Pot: <input type="text" name="pot" value="<?php echo $pot;?>">
<span class="error">* <?php echo $potErr;?></span>
<br><br>
Stack: <input type="text" name="stack" value="<?php echo $stack;?>">
<span class="error">* <?php echo $stackErr;?></span>
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
echo "<h2>Geo Sizing:</h2>";
echo "<b>2-street sizing plan:</b> <br>";
echo "Bet " . round($b11) . " then bet " . round($b12) .".";
echo "<br><br>";
echo "<b>3-street sizing plan:</b> <br>";
echo "Bet " . round($b21) . " then bet " . round($b22) . " then bet " . round($b23) .".";
?>
</body>
</html>
答案 0 :(得分:1)
使用html
扩展程序,您的PHP实例无法处理它,因此它不会。您可以修改服务器,以便将html
和htm
文件作为PHP处理;或者您可以将文件重命名为.php
。
对于后一种解决方案,请参阅此主题; Process HTML files like PHP