I am looking to build a simple one-field form that will take the number entered and run it through a formula and display the result underneath on a webpage for a school project. Similar to a paypal fee calculator. NO more, no less.
I can handle HTML, CSS, JS, but am pretty PHP-tarded.
Is there something I can read to learn how to go about this? I tried searching but am not sure exactly what I should be searching for.
Thanks
Name the field that you are entering, i.e.
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="value" value="">
<input type="submit" value="Submit">
</form>
<?php
$value=$_POST['value'];
if ($value!=""){
//RUN FORMULA HERE:
$total=$value * 1.02;
echo $total;
}
?>
Using this method will allow you to continue entering numbers until you are done.
Next time see php manual or google... there is a lot of similars...
<?php
if(!isset($_POST['number']))
{
?>
<form method="POST">
<input type="text" value=0 name='number'/>
<input type="submit" />
</form>
<?php
}
else
{
$num = $_POST['number'];
$result = ($num * $num) + $num;
echo $result;
}
?>