I have two .php files cotiza.php
andinsertCot.php
In cotiza.php I have some inputs and a button, the button has a onClick
function, I take the values of my inputs and send them to the javascript function
:
<button type="button" onClick="GuardacotizacionaBD(document.getElementById('pais').value, document.getElementById('proyecto').value,
document.getElementById('notas').value, document.getElementById('formapago').value, document.getElementById('fechaentrega').value,
document.getElementById('flete').value,
document.getElementById('instalacion').value,
document.getElementById('venta').value,
document.getElementById('total').value);">Realizar</button> //It works, I have not problem with this
in my function I get the values and I send them to insertaCot.php
function GuardacotizacionaBD (pais, proyecto, notas, formapago, fechaentrega, flete, instalacion, venta, total)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST","insertaCot.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("pais="+pais+"&proyecto="+proyecto);
location.reload(true)
}
In insertaCot.php I receive them: To try to do an INSERT to a table on MySql
<?
include('conexion.php');
$coninsert=conexion();
$pais= $_POST['pais'];//this is line 22
$proyecto= $_POST['proyecto'];//this is line 23
//all my vars
?>
BUT i get this:
Undefined index: pais in C:\xampp\htdocs\insertaCot.php on line 22
Undefined index: proyecto in C:\xampp\htdocs\insertaCot.php on line 23
I print my form on insertCot, but it doesn't have values:
Array
(
)
Any idea about what could i do?
I have the same dimamic in 2 .php
files and the work.
thank you