PHP表单发布到自身

PHP表单发布到自身,php,html,forms,Php,Html,Forms,我一直在尝试将表单中包含的一些信息发布到表单本身。但是我不明白为什么它不起作用。当我从HTML页面发布数据时,它可以工作,但当我将信息发布到自身时,它就不工作了 代码如下: $country = isset($_POST['country']) ? $_POST['country'] : 'Belize'; $number_of_guests = isset($_POST['number_of_guests']) ? $_POST['number_of_guests'] : 2; $f

我一直在尝试将表单中包含的一些信息发布到表单本身。但是我不明白为什么它不起作用。当我从HTML页面发布数据时,它可以工作,但当我将信息发布到自身时,它就不工作了

代码如下:

    $country =  isset($_POST['country']) ? $_POST['country'] : 'Belize';
$number_of_guests = isset($_POST['number_of_guests']) ? $_POST['number_of_guests'] : 2;
$from =  isset($_POST['price_range_from']) ? $_POST['price_range_from'] : 200;
$to =  isset($_POST['price_range_to']) ? $_POST['price_range_to'] : 2000;
当我发布来自HTML表单的信息时,它可以正常工作,但在提交给它自己时,所有变量都包含“on”的值。我不知道我遗漏了什么或没有正确实施

以下是HTML表单代码:

<form action="find_results.php" method = "post">
    <strong>Select the Country</strong><br />
    <input id = 'c1' type= "radio" name= "country" checked/> Mexico <br />
    <input id = 'c2' type= "radio" name= "country" /> Belize <br />
    <input id = 'c3' type = "radio" name= "country" />Jamaica <br />
    <input id = 'c4' type = "radio" name= "country" />Thailand <br />
    <input id = 'c5' type = "radio" name= "country" />Turks & Caicos 
    <hr />

    <strong>Number of Guests</strong><br />
    <input id = 'n1' type= "radio" name= "number_of_guests" /> 2
    <input id = 'n2' type= "radio" name= "number_of_guests" /> 4
    <input id = 'n3' type= "radio" name= "number_of_guests" /> 6        
    <input id = 'n4' type= "radio" name= "number_of_guests" /> 8
    <input id = 'n5' type= "radio" name= "number_of_guests" /> 10+
    <hr />

    <strong>Price Range(From)</strong><br />
    <input id = 'from1' type= "radio" name= "price_range_from" /> 200
    <input id = 'from2' type= "radio" name= "price_range_from" /> 300
    <input id = 'from3' type= "radio" name= "price_range_from" /> 400
    <input id = 'from4' type= "radio" name= "price_range_from" /> 500
    <input id = 'from5' type= "radio" name= "price_range_from" /> 600 or More 
    <hr />

    <strong>Price Range(Upto)</strong><br />
    <input id = 'to1' type= "radio" name= "price_range_to" /> 500
    <input id = 'to2' type= "radio" name= "price_range_to" /> 600
    <input id = 'to3' type= "radio" name= "price_range_to" /> 700
    <input id = 'to4' type= "radio" name= "price_range_to" /> 800
    <input id = 'to5' type= "radio" name= "price_range_to" /> 900 or More
    <br />

    <input type="submit" value="Submit" name='submit' />
</form>

选择国家/地区
墨西哥
伯利兹
牙买加
泰国
特克斯和凯科斯群岛
客人人数
2. 4. 6. 8. 10+
价格范围(从)
200 300 400 500 600或以上
价格范围(最高)
500 600 700 800 900或以上

表单中没有设置值。当指向另一页时,这是如何工作的

<input id = 'c1' type= "radio" name= "country" checked value='mexico' />

您确实需要在表单中设置
value='something'
,以便传递正确的数据。在传递表单元素时,您可能会将它们设置为“on”,但其
值中没有任何信息。

同意Fluffeh的说法。特定标记的“值”将转发到PHP代码。没有这些值,就无法获得所需的结果

<input id = 'c1' type= "radio" value="Mexico" name= "country" checked="checked" /> Mexico <br />
<input id = 'c2' type= "radio" value="Belize" name= "country" /> Belize <br />
墨西哥
伯利兹

在PHP中,这些值将为国家设置。

我们需要查看HTML表单的简化版本。请删除任何样式等。创建更简单的样式的过程可能也会帮助您找到根本原因。代码就在那里,只是没有在问题中设置为
code