I am coding a php/html page, with some javascript functions.
I want to perform an INSERT on my MySQL Database if the result of one of my javascript functions is equal to 1.
01) How can I access the result of this javascript function in PHP code?
02) When executing this function, I can set the value of a HTML text form, but I get "Undefined index" when I try to get this value by $_GET['value']. Any sugestions here?
Thanks in advance!
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script language="javascript">
function function2( a, b, c, d, e, f, g, h)
{
//calculations here
var elem = document.getElementById("result");
elem.value = result;
return result;
}
function function1 ()
{
//set values of form1
function2();
}
</script>
</head>
<body>
<script>
window.onload = function()
{
function1();
}
</script>
<?php
//MySQL to get a, b, c, d, e, f values
?>
<form name="form1" id="form1" method="get">
<input type="hidden" name="g" value=""> </input>
<input type="hidden" name="h" value=""> </input>
</form>
<form name="form2" id="form2" method="get">
<input type="text" name="a" value="<?php echo $a; ?>"> </input>
//same to b, c, d, e, f
<input type="text" id='result' name="result" value="0"> </input>
</form>
<?php
//perform MySQL operation if function2 == 1
//or if $_GET['result'] == 1
?>
</body>
</html>