1

基本的なフォーム ページを作成しましたが、Aptana、WAMP、および基本的な 1and1 でホストされたページを介して、フォーム フィールドが $_POST スーパーグローバルを通過できません。

index.html ページは次のとおりです。

<html>
<head>
    </head>
    <body>
        <p>Type in the areas</p>
    <form action="keywords.php" method="POST">
        <label for="Area1"> 1:</label>
        <input type="text" id="Area1" name="first area /"><br />
        <label for="Area1"> 2:</label>
        <input type="text" id="Area2" name="second area /"><br />
        <label for="Area1"> 3:</label>
        <input type="text" id="Area3" name="third area /"><br />
        <label for="Area1"> 4:</label>
        <input type="text" id="Area4" name="fourth area /"><br />
        <label for="Area1"> 5:</label>
        <input type="text" id="Area5" name="fifth area /"><br />
        <label for="Area1"> 6:</label>
        <input type="text" id="Area6" name="sixth area /"><br />
        <label for="Area1"> 7:</label>
        <input type="text" id="Area7" name="seventh area /"><br />
        <label for="Area1"> 8:</label>
        <input type="text" id="Area8" name="eighth area /"><br />
            <input type="submit" value="Run" name="Run">
            </form>
    </body>
</html>
?>

keyword.php に渡すもの

<?php

 if(isset($_POST['submit'])){
     echo "test";


    $area1 = $_POST['Area1'];
    $area2 = $_POST['Area2'];
    $area3 = $_POST['Area3'];
    $area4 = $_POST['Area4'];
    $area5 = $_POST['Area5'];
    $area6 = $_POST['Area6'];
    $area7 = $_POST['Area7'];
    $area8 = $_POST['Area8'];


    echo $area1;
 }
 ?>

親愛なる主よ、私は何を間違っていますか。穏やかな。PHP 5.3.4

4

3 に答える 3

2

$_POST名前に基づいて変数が挿入されます。です$_POST['first area']

また、コピーが悪いかどうかはわかりませんが、名前の中にスラッシュがあってはなりません...引用符の外にある必要があります。例えば:

<input type="text" id="Area1" name="first area" /><br />
于 2011-03-20T02:23:12.367 に答える
2

エラー、PHP コードでは、フォーム要素の name 属性ではなく、HTML id 属性で指定した値を参照しています。ブラウザーは name 属性をフォーム要素の名前として渡します。$_POST['first area'] などを試してください:)

于 2011-03-20T02:23:22.037 に答える
1

実際には、すべての入力を 1 つの配列として渡すことができます。

これが例です。

<html>
<head>
    </head>
    <body>
        <p>Type in the areas</p>
    <form action="keywords.php" method="POST">
        <label for="Area1"> 1:</label>
        <input type="text" id="Area1" name="area[]"><br />
        <label for="Area1"> 2:</label>
        <input type="text" id="Area2" name="area[]"><br />
        <label for="Area1"> 3:</label>
        <input type="text" id="Area3" name="area[]"><br />
        <label for="Area1"> 4:</label>
        <input type="text" id="Area4" name="area[]"><br />
        <label for="Area1"> 5:</label>
        <input type="text" id="Area5" name="area[]"><br />
        <label for="Area1"> 6:</label>
        <input type="text" id="Area6" name="area[]"><br />
        <label for="Area1"> 7:</label>
        <input type="text" id="Area7" name="area[]"><br />
        <label for="Area1"> 8:</label>
        <input type="text" id="Area8" name="area[]"><br />
            <input type="submit" value="Run" name="Run">
            </form>
    </body>
</html>

1 つの変数を取得します。$_POST['area']この変数は、反復できる 8 つの値の配列です。

于 2011-03-20T03:37:35.310 に答える