是否可以使用onsubmit
JavaScript 从 PHP 调用函数?如果是这样,有人可以给我一个如何完成的例子吗?
function addOrder(){
$con = mysql_connect("localhost", "146687", "password");
if(!$con){
die('Could not connect: ' . mysql_error())
}
$sql = "INSERT INTO orders ((user, 1st row, 2nd row, 3rd row, 4th row)
VALUES ($session->username,1st variable, 2nd variable, 3rd variable, 4th variable))";
mysql_query($sql,$con)
if(mysql_query($sql,$con)){
echo "Your order has been added";
}else{
echo "There was an error adding your order to the databse: " . mysql_error();
}
}
这就是我要调用的函数。它是一个订购系统,您输入您想要的每件商品的数量,点击提交,它应该将订单添加到表格中。