0
I need to do this: Create an HTML form with two text fields a div for presentation of the results and a button of type Submit. 1 - Create a PHP script, which receives form data and informs in the div element of form the result of the sum of the numbers
I tried to do but is giving error and I do not know solve because I am beginner in programming
HELP!!!!!
<body>
<div>
<form action="../model/numeros.php" method="POST">
Informe um número
<input type="text" placeholder="Número" name="n1"><br>
Informe outro número
<input type="text" placeholder="Número" name="n2"><br>
<input type="submit"></input><br>
<b>Resultado da soma:</b>
</div>
<div>
<?php
require_once '../model/numeros.php';
$o = new numeros();
$dados=$o->Somar();
echo $dados;
?>
</div>
My php class:
<?php
//$n1=$_GET['n1'];
//$n2=$_GET['n2'];
class numeros{
$n1=$_POST["n1"];
$n2=$_POST["n2"];
public function Somar()
{
$total=$n1+$n2;
return $total;
}
}
?>
what is the error that is giving? take the action from the form
– Tiago Gomes