Below is the code I am sharing, where data from a JavaScript file is stored in a MySQL database.
The code in the JavaScript file is:
function set_shield(t_value){
var ok = confirm("Are you sure want Lock Value?")
if (ok)
{
xmlhttp.open("GET","p_scripts/dataStore.php?set_value="+shield.value,true);
xmlhttp.send();
window.location.reload(true);
}
}
The code in my dataStore.php file is as follows:
<?php
session_start();
$set_value=$_GET[set_value];
include("php_scripts\db.php"); // connection create here
$date =date("Y-m-d H:i:s");
mysql_query("Update user SET p1='y' WHERE user_id='$_SESSION[login_user]'");
mysql_query("INSERT power_play (user_id, p_play_type, date_of_play, set_value) VALUES ('$_SESSION[login_user]','1','$date','$set_value')");
?>