我应该放什么代码以便我的输出"你的车费用"不会表现出来 我一直想弄清楚要放什么但是失败了。
<?php
// define variables and set to empty values
$costErr = $modelErr = "";
$cost = $model = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["cost"])) {
$costErr = "Cost is required";
} else {
$cost = test_input($_POST["cost"]);
}
if (empty($_POST["model"])) {
$modelErr = "Model is required";
} else {
$model = test_input($_POST["model"]);
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
当用户在字段上放置内容时输出,但如果用户不想在字段上输入值,则此输出不应显示我该怎么做?
<?php
if (isset($_POST["age"]) && $_POST["age"] === "1 Year" && $_POST["conditon"] === "Yes") {
if ($_POST["age"] === "1 Year" && $_POST["conditon"] === "Yes") {
echo "Your car Costs " .$cost;
echo "<br>";
echo "The model of your car is " .$model;
echo "<br>";
$price = $cost - ($cost * .20);
echo "Your car costs in good condition " .$price;
} else if($_POST["age"] === "1 Year" && $_POST["conditon"] === "No") {
echo "Your car Costs " .$cost;
echo "<br>";
echo "The model of your car is " .$model;
echo "<br>";
$price = $cost - ($cost * .20) - ($cost * .10);
echo "Your car costs in bad condition " .$price;
}
}
?>