my Question is how can i implement that i can click on a button and then he will display every 2 or every 5 seconds a new table (with entries from the database with mysql) .
Currently Im only showing the table from database with php, but i want to refresh it live in a interval with ajax, but I really don't know how to.
My Currently php file is here (the method to show the entries is also in this file and this methods name is showTenLatestLoginActivities() :
<?php
include '../../resources/php/user_utilities.php';
include '../../resources/php/string_utilities.php';
include '../../resources/php/website_utilities.php';
rejectUserThatisNotLoggedInFromIframe();
?>
<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="Edit here your Security Settings!">
<meta name="robots" content="index, follow">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="../../resources/css/style.css">
<link rel="stylesheet" href="../../resources/fonts/icomoon/style.css">
<link rel="stylesheet" href="../../resources/css/bootstrap.min.css">
<link rel="stylesheet" href="../../resources/css/jquery-ui.css">
<link rel="stylesheet" href="../../resources/css/owl.carousel.min.css">
<link rel="stylesheet" href="../../resources/css/owl.theme.default.min.css">
<link rel="stylesheet" href="../../resources/css/owl.theme.default.min.css">
<link rel="stylesheet" href="../../resources/css/jquery.fancybox.min.css">
<link rel="stylesheet" href="../../resources/css/bootstrap-datepicker.css">
<link rel="stylesheet" href="../../resources/fonts/flaticon/font/flaticon.css">
<link rel="stylesheet" href="../../resources/css/aos.css">
<link rel="stylesheet" href="../../resources/css/other.css">
<link rel="stylesheet" href="../../resources/css/profile_tab.css">
<link rel="stylesheet" href="../../resources/css/checkbox.css">
<script src="../../resources/js/jquery-3.3.1.min.js"></script>
<script src="../../resources/js/website_utilities.js"></script>
<body onload="">
<br>
<h1>Security</h1>
<p>Manage suspicious logins from other people, activities and more. This area is solely responsible for the security of your account.</p>
<p>OTHER OPTIONS..</p>
<h2>Login History</h2>
<p>Here you can see the last 10 login activities. Who and at what time logged in with their IP address under your name.</p>
<?php showTenLatestLoginActivities(); ?>
<p></p>
<h2>Activity Monitor</h2>
<br><br>
<script> AJAX CODE TO REFRESH LIVE THE TABLE </script>
<?php
function showTenLatestLoginActivities(){
include '/var/www/vhosts/prodigy-official.de/httpdocs/dbusers.php';
$sql = "SELECT browser,os,ip_address,country,login_time FROM `user.login_history` WHERE
username_id='".getUserIdInDatabase()."' ORDER BY id DESC";
$result = mysqli_query($db,$sql);
if (mysqli_num_rows($result) > 0){
echo '<table>';
echo '<tr>';
echo '<th>Browser</th>';
echo '<th>Operating System</th>';
echo '<th>IP Address</th>';
echo '<th>Country</th>';
echo '<th>Login Time</th>';
echo '</tr>';
while($row = mysqli_fetch_array($result))
{
echo '<tr>';
echo "<td>" . $row['browser'] . "</td>";
echo "<td>" . $row['os'] . "</td>";
echo "<td>" . $row['ip_address'] . "</td>";
echo "<td>" . $row['country'] . "</td>";
echo "<td>" . $row['login_time'] . "</td>";
echo '</tr>';
}
echo '</table>';
} else {
echo '(No Data found)';
}
mysqli_close($db);
}
?>
Aucun commentaire:
Enregistrer un commentaire