I need the currently viewed page to be stored in php mysql. I have a single line of html page and i need to store the data like if users visit about us then the url followed by about. Since it is a single html page index.html and all the menus are provided within that index.html
I already have a db and PHP code but did not work as expected
$page = "https://chennaifreelancers.com".$_SERVER['HTTPS_HOST']."".$_SERVER['PHP_SELF'];
I tried
$page="https://chennaifreelancers.com".$_SERVER['HTTPS_HOST']."".$_SERVER['index.html'];
and
$page="https://chennaifreelancers.com".$_SERVER['HTTPS_HOST']."".$_SERVER['SERVER_NAME'];
Included this as well in my html page
<header class="bgimg-1 w3-display-container w3-grayscale-min" id="home" form method="post" action="get_details.php">
PHP Version: 5.5 and Maria DB: 10.2
#get_details.php
<?php
// require ReCaptcha class
require_once("DBConfig.php");
$ipaddress = $_SERVER['REMOTE_ADDR'];
$page= https://chennaifreelancers.com".$_SERVER['HTTPS_HOST']."".$_SERVER['index.html'];
$referrer = $_SERVER['HTTP_REFERER'];
$datetime = date("F j, Y, g:i a");
$useragent = $_SERVER['HTTP_USER_AGENT'];
$query = mysql_query("SELECT `ip` FROM `visitors_table` WHERE `ip` = '$ip' ");
if(mysql_num_rows($query)> 0) { // if return 1, email exist.
} else { // else not, insert to the table
$query = mysql_query("INSERT INTO `visitors_table` (`ip` ,`current_page`,`referrer`,`time` ,`user_agent`)
VALUES ('$ipaddress','$page','$referrer','$datetime','$useragent')");
$result=mysql_query($query);
$result=mysql_query($query);
}
close($query);
Actual : https://chennaifreelancers.com/get_details.php this is recorded in the DB but
Expected: https://chennaifreelancers.com/#about etc i require this to be stored in DB