I need for someone to advise how I'm going wrong with passing my
JS "function(OnCalc()" in the FORM named "calculator.html" to my database:
My form presents as desired but submitting enters 0.00 values.
I just need to know if the following syntax and procedures are correct.
Thanks.
--------------------------------------------------------
this is from "calculator,html"
-------------------------------------------------------
--------------------------------------------------------
this is from "calculator.php":
>
--------------------------------------------------------
JS "function(OnCalc()" in the FORM named "calculator.html" to my database:
My form presents as desired but submitting enters 0.00 values.
I just need to know if the following syntax and procedures are correct.
Thanks.
--------------------------------------------------------
this is from "calculator,html"
Code:
<FORM name="Keypad" action="http://localhost/home/calc_redirect.php" method="post"> // ??????
if (value1 == parseInt(num))
{value1.value = parseInt(value1.value)}
else
{value1.value = parsefloat(value1.value)}
if (value2 == parseInt(num))
{value2.value = parseInt(value2.value)}
else
{value2.value = parsefloat(value2.value)}
if (total == parseInt(num))
{total.value = parseInt(total.value)}
else
{total.value = parsefloat(total.value)}
/* var expression = value1 + op +value2 +'='+ total;
alert(expression); */
}
function OnCalc(value1,op,value2,total)
{
</SCRIPT>
PHP:
<?php
// name of this is "calc_redirect"
/* The header() sends a raw HTTP/1.1 specification specific header. header() must be called before any actual output is sent */
/* Redirect browser */
header("Location: http://localhost/home/calculator.php"); // ?????
exit;
?>
this is from "calculator.php":
PHP:
$query = "
INSERT INTO calculator (purpose, value1, op, value2, total)
VALUES ('$purpose','$value1','$op','$value2','$total')";
mysqli_query($con, $query);
mysqli_close($con);
?
Code:
<a href="http://localhost/home/calc_print.php">Print</a>
</center></body></html>