Organizational Research By

Surprising Reserch Topic

javascript and php functions


javascript and php functions  using -'php,javascript,function'

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();
    }
}


That's 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.
    

asked Oct 11, 2015 by thiru
0 votes
9 views



Related Hot Questions

7 Answers

0 votes
NULL
answered Oct 11, 2015 by abhimca2006
0 votes
NULL
answered Oct 11, 2015 by kinnari
0 votes
NULL
answered Oct 11, 2015 by 20shahi
0 votes
NULL
answered Oct 11, 2015 by pradip.bhoge
0 votes
NULL
answered Oct 11, 2015 by amit_cmps
0 votes
NULL
answered Oct 11, 2015 by dhananjayksharma
0 votes
NULL
answered Oct 11, 2015 by dahiyabecomp

...