Ik wil een factureringsprogrammaatje maken met PHP en dit programma is een test. Echter, hij pakt de totalen niet,zowel bij 1 als 2 als 1 + 2.
Kan iemand me helpen?
<?php
global $test1;
global $test2;
global $p1;
global $p2;
global $t1;
global $t2;
global $som;
function uitrekenen (){
$test1 = ($_POST['Getal1']);
$test2 = ($_POST['Getal2']);
$p1 = ($_POST['Prijs1']);
$p2 = ($_POST['Prijs2']);
$t1 = $test1 * $p1;
$t2 = $test2 * $p2;
$som = $t1 + $t2;
echo $t1;
echo $t2;
echo $som;
}
?>
<?php
if ( isset($_POST['Submit']) ){ uitrekenen();}
?>
<?php
function ShowForm()
{
global $test1;
global $test2;
global $p1;
global $p2;
global $t1;
global $t2;
global $som;
?>
<html>
<head> FunctieTest
<title>LatenZien</title>
</head>
<body>
<form method="post" action="FunctieTest.php">
<br>Aantal1: <input type="text" name="Getal1"> Prijs1: <input type="text" name="Prijs1"> Totaal1: <input type="text" name="Totaal1" value= <?php print $t1; ?> ><br>
Aantal2: <input type="text" name="Getal2"> Prijs2: <input type="text" name="Prijs2"> Totaal2: <input type="text" name="Totaal2" value= <?php print $t2; ?> ><br>
Totaal: <input type="text" name="Optelling" value= <?php print $som; ?> ><br>
<input type="Submit" value="Test" name="Submit">
</form>
<?php
}
ShowForm();
?>
655 views