I have a function in a separate PHP page to add information to a MySql database. However if I want to pass in a paramater which is only available in my JavaScript file.
PHP Function in ModelBrowse.php
function databaseAdd($lockval)
{
include_once('../dbConnect.php');
$con = connect();
if (!$con) {
trigger_error(mysqli_error($con), E_USER_ERROR);
die('Could not connect: ' . mysqli_error($con));
}
if ($lockval = "locked")
{
$sql = "INSERT INTO model(lock) VALUES ('lock')";
}
if ($lockval = "unlocked")
{
$sql = "INSERT INTO model(lock) VALUES ('unlock')";
}
mysqli_query($con, $sql)
mysqli_close($con);
}
I want to call databaseAdd in my JavaScript file. I know I must use AJAX but I am confused on how I must do this.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire