Is it possible to call a function from PHP using onsubmit from javascript? If so could someone give me an example of how it would be done?
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();
}
Thats the function I am wanting to call. Its an ordering system, you type in how much of each item you want, hit submit and it should add the order to the table.