您好我正在尝试实施一项小功能,包括价格检查(现在只是测试!)但是当我点击提交时,没有任何内容可以回复给我!这是我的代码:
<!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>
&#13;
感谢您的帮助!
答案 0 :(得分:1)
未定义表单方法和操作属性。您应该定义用户数据的发布位置。 试试这段代码,
<!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>