0
<!DOCTYPE html>
<html>
<head>
<title>Exercicio 3</title>
</head>
<body>
<?php
$km = $_POST['km'];
$valcombu =$_POST['valcombu'];
$gaston =$_POST['gaston'];
$km = 0;
$valcombu;
$gaston = 0;
$gaston = ($km / 8) * $valcombu;
echo "Você vai gastar R$" .$gaston;
?>
<form action="" method="POST">
<label for="km" >Entre com a quilometragem percorrida</label><br>
<input type="number" name="km">
<br><br>
<label for="valcombu">Entre com o preço do combustivel</label><br>
<input type="number" name="valcombu">
<br>
<input type="submit" name="Enviar">
<input type="reset" name="Resetar">
</form>
</body>
</html>
Still not returning anything, always back to the same home screen
– Breno Brogini
It goes back to the same screen because the form action is calling the same screen. But if you observe, will appear the message "You will spend $ " with a calculated value. You can create another file that does this calculation, and call it in the action.
– André Lins
So, this I know should work, but the problem is that the exercise in question was to be done with php inside html, outside this I’m having the same problem with other 3 exercises.
– Breno Brogini
I edited the answer, try it now the way I specified and see if it meets what you’re expecting.
– André Lins
It’s not working yet, I thought it would be because I’m using XAMPP, but even without it still comes back nothing but a home screen .
– Breno Brogini
Put in question the prints of the screens you are getting.
– André Lins
File is with your extension as . php? Nothing after that.
– André Lins
Ahhh, that’s right, thank you. There’s a way to get Echo out from under the data without going to "another page" so to speak?
– Breno Brogini
Yes, I edited the answer here, put the answer as correct to give the question as finalized
– André Lins
But now after I send the information it goes to a blank screen
– Breno Brogini
Was inside the if, updated.
– André Lins
Well, it’s still going to a "new page" so to speak, but it has helped a lot with the real problem of the question, thank you very much
– Breno Brogini