私はこれがあなたの多くにとって非常に簡単だと確信しています!私は基本的なHTML/PHPフォーム処理を学びたいと考えています。このサイトは、ローカルのApacheサーバーでホストされています。 PHPが正常に動作していて、サーバがうまく動作していることがうれしいです。HTMLフォームを処理する単純なPHP
私は2つのファイルを持っています.1つはsettings.htmlです。ユーザーは3つの要素の形式を持ち、フロート値を入力できます(湿度、温度、光の許容値)。送信ボタンは、process.phpという3つの値を表示する別のファイルをトリガします。コードは以下の通りである:
settings.html:
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<meta http-equiv="refresh" content="179" >
<title>Sparks - Settings</title>
<link rel="stylesheet" type="text/css" href="css/default.css">
</head>
<body>
<div id="logo">
<img style="width: 335px; height: 142px;" alt="ESP8266 Logo" src="images\imgESP8266.png">
</div>
<br>
<form method="post" action="php/process.php">
Humidity Tolerance : <input type="float" name="humTolerance" placeholder="Enter %" /><br />
Temperature Tolerance : <input type="float" name="tempTolerance" placeholder="Enter %" /><br />
Light Tolerance : <input type="float" name="lightTolerance" placeholder="Enter %" /><br />
<input type="submit" value="Submit" />
</form>
</body>
<html>
PHP/process.php:
<?php //process.php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$humTolerance = $_POST["humTolerance"];
$tempTolerance = $_POST["tempTolerance"];
$lightTolerance = $_POST["lightTolerance"];
}
echo <<<_END
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<meta http-equiv="refresh" content="179" >
<title>Sparks - Settings</title>
<link rel="stylesheet" type="text/css" href="css/default.css">
</head>
<body>
humTolerance is: $humTolerance<br>
tempTolerance is: $tempTolerance<br>
lightTolerance is: $lightTolerance<br>
</body>
</html>
_END;
?>
これはHTTPエラー500を生産していると私は理由を見ることはできません。助けてもらえますか?ありがとう。
(最初の)問題は、あなたのheredocの終了識別子http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredocにあります。その前にスペースが含まれています。 –
2番目の: 'type =" float "は入力のための有効な型ではありませんhttps://developer.mozilla.org/en/docs/Web/HTML/Element/input --- http:// html5doctor .com/html5-forms-input-types/--- https://www.w3.org/wiki/HTML5_form_additions –
あなたのPHPページでhttp 500を取得した場合、PHPにエラーがあります。表示するようにphp.iniを設定しますエラーメッセージを表示してコードをデバッグするのに役立ちます。 –