简体   繁体   English

html/php 表单不输出

[英]Html/php form not out-putting

hi i'm trying to implement a small feature including a price checker (just testing for now!) but when i hit submit nothing is ecohed back to me!嗨,我正在尝试实现一个小功能,包括价格检查器(现在只是测试!)但是当我点击提交时,什么都没有回复给我! here is my code:这是我的代码:

 <!doctype html> <head> <meta charset="UTF-8"> <title>ValleyRangesPriceCheck</title> <link REL='stylesheet' TYPE='text/css' HREF='Style.css'> </head> <body> <form> <input type="date" name="check-in"> <input type="date" name="check-out"> <input type="number" name="num-of-guests" min="1" max="10" placeholder="Guests"> <select name="operator"> <option>Candelight</option> <option>Misty Woods</option> <option>Beach Mont</option> </select> <button type="submit" name="submit" value="submit">submit</button> </form> <p> The Answer Is:</p> <?php if (isset($_GET['submit'])){ $result1 = $_GET['check-in']; $result2 = $_GET['check-out']; $operator = $_GET['operator']; switch ($operator){ case "Candelight": echo $result1 + $result2; break; } } ?> </body> </html>

Thanks for the help!感谢您的帮助!

The form method and action attributes are not defined.未定义表单方法操作属性。 You should define where the user data should be posted.您应该定义用户数据的发布位置。 Try this code,试试这个代码,

<!doctype html>
<head>
    <meta charset="UTF-8">    
    <title>ValleyRangesPriceCheck</title>
    <link REL='stylesheet' TYPE='text/css' HREF='Style.css'>
</head>
<body>
    <form  method="get" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
        <input type="date" name="check-in">
        <input type="date" name="check-out">
        <input type="number" name="num-of-guests" min="1" max="10" placeholder="Guests">
        <select name="operator">
            <option>Candelight</option>
            <option>Misty Woods</option>
            <option>Beach Mont</option>
        </select>

        <button type="submit" name="submit" value="submit">submit</button>
    </form>
    <p> The Answer Is:</p>
    <?php
        if (isset($_GET['submit'])){
            $result1 = $_GET['check-in'];
            $result2 = $_GET['check-out'];
            $operator = $_GET['operator'];
                switch ($operator){
                    case "Candelight":
                        echo $result1 + $result2;
                        break;
                }
        }
    ?>
</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM