如何在php文件中接收我的变量(来自javascript代码)
我有两个.php文件如何在php文件中接收我的变量(来自javascript代码),javascript,php,mysql,post,Javascript,Php,Mysql,Post,我有两个.php文件cotiza.php和insertCot.php function GuardacotizacionaBD (pais, proyecto, notas, formapago, fechaentrega, flete, instalacion, venta, total) { xmlhttp=new XMLHttpRequest(); xmlhttp.open("POST","insertaCot.php",true); xmlhttp.setRequestHeader(
cotiza.php
和insertCot.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)
}
在cotiza.php中,我有一些输入和一个按钮,该按钮有一个onClick
函数,我获取输入值并将其发送到javascript函数
:
<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
在insertaCot.php中,我收到了它们:尝试在MySql上插入表
<?
include('conexion.php');
$coninsert=conexion();
$pais= $_POST['pais'];//this is line 22
$proyecto= $_POST['proyecto'];//this is line 23
//all my vars
?>
我在insertCot上打印表单,但它没有值:
Array
(
)
知道我能做什么吗?
我在2.php
文件和工作中有相同的dimaic
谢谢您请向我们展示您的JS代码中的表单HTML代码。
警报(pais)
。如果这是空的,那么你的JS代码和/或html不知何故是错误的。我做到了,我拥有我所有变量的值!(pais,proyecto…)但我不会在下一个php文件(insertcot.php)中收到它们@MarcBthen检查php代码var\u dump($\u SERVER['REQUEST\u METHOD'],$\u POST)
并查看真正的内容。它是空的@马尔布。。。嗯,那么。。。我能做什么?
Array
(
)