Sempervivum
A good day to you Mr Sempervivum, hope you are in good health today & always, and thank you for spending some of your time helping me in my coding problems. below is the actual codes i am working in...
<script> //from a script file
function jsonfunct(){
var betsinfo = {};
betsinfo.amtbet = xamtbet; //variable xamtbet from input tag
betsinfo.fightno = yfightno; //variable yfightno from span tag
betsinfo.fighttime = document.getElementById('digiClock').innerHTML;
console.log(betsinfo);
$.ajax({
url: "fight_vue_validation.php" + Date.now(),
type: "POST",
data: { betsinfo : JSON.stringify(betsinfo)},
success: function(res) {
console.log(res);
}
})
</script>
<?php //from a php file
include("connection.php");
$jsdata = isset($_POST['betsinfo']) ? json_decode($_POST['betsinfo']) : ""; //isset is used to avoid the error message UNDEFINED INDEX
print_r($jsdata);
$mfightdate=date("Y/m/d");
$mfighttime = isset($jsdata->fighttime) ? $jsdata->fighttime : "";
$mfightno= isset($jsdata->fightno) ? $jsdata->fightno : "";
$mbetamtmeron = isset($jsdata->amtbet) ? $jsdata->amtbet : "";;
$mbetamtwala = 0;
$mwinside = "meron";
$mbetamtwin = 240;
$mID = $_SESSION['member_info']['member_id'];
$mBetVueHistqry = "INSERT INTO memberbethistory (member_id, fightbetdate, fightbettime, fightno, betamtmeron, betamtwala, winside, betamtwin)
VALUES ('$mID','$mfightdate','$mfighttime','$mfightno','$mbetamtmeron','$mbetamtwala','$mwinside','$mbetamtwin')";
mysqli_query($conn, $mBetVueHistqry) or die("Connection error");
?>
Now, a new problem arises, or there may be an error in my codings that causes it.
The $_SESSION[''][''] becomes invisible or unaccessible, as the error message says ... "UNDEFINED VARIABLE"
When at first load of the page, the $SESSION appears/saved in the database, automatically (even the jsonfunct() is not clicked), but after I clicked the jsonfunct(), the $SESSION disappears/not saved in the database
The other variables that was defined in php are not affected by json.
Also, how it is that the data have been saved in the database even if the jsfunct() is not yet been clicked, even i clicked the browser "refresh", the data is automatically been saved?
Thank you again, for your answers and patience. Be safe always!!!