I am having some issue that is facing me with running the following dismiss functions,
So page with an alert bootstrap that I have named as notifications-success.php goes as follows:
<?php
$root = realpath(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']) );
include ($root . '/insights/ss/onix.php');
$result = mysqli_query($mysqli,"select * from notifications where seen = 0");
if ($result)
{
if($result->num_rows) {
while($row = mysqli_fetch_assoc($result))
{?>
<div class='alert alert-success alert-dismissible' role='alert' style='margin-left:-12px;'>
<button type="button" class="close" onClick="updateId('<?php echo $row['id'];?>')" data-dismiss="alert" aria-label="Close" style="float:left!important; border:0; background:none;"><span aria-hidden="true">×</span></button>
<strong><span class="text-success" style="margin-top:-50px;"><i class='fa fa-check'></i> File has been moved successfully</strong><br>To confirm reading this message please press x button </span></div>
<?php }
}
}
?>
<script>
function updateId(id)
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "dismisssuccess.php?id=" +id, true);
xmlhttp.send();
}
</script>
Action file which is dismisssuccess.php goes as follows:
<?php
if(isset($_GET['id']) && !empty($_GET['id']))
{
$id = $_GET['id'];
$ip = getenv('REMOTE_ADDR');
$root = realpath(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']) );
include ($root . '/insights/ss/onix.php');
$update = "UPDATE notifications SET seen = 1 , seenby = '$ip' WHERE id = '".$id."'";
if (mysqli_query($mysqli, $update))
{
echo "success";
}
else
{
echo "There is some error";
}
die;
}
?>
Now when I press x , the update statement doesn't actually run, meanwhile, when i open dismisssuccess file by http with relevant id it works fine with no error and does the update required, also works fine only when I change the table to be update.
Does anyone have clue what could be possible reason behind this issue?
Thank you in advance
To confirm reading this message please press x button ` – Professor Abronsius Oct 21 '21 at 09:46