what code should i put so that the my output "your car cost" won't show
i've been trying to figure out what to put but failed.
<?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;
}
?>
This is output when the user puts something on the field, but if the user won't enter a value on the field this output should not show up what should i do with this?
<?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;
}
}
?>