Hi,
I'd like to save every unique visits in my database; then I'm going to elaborate data to get visits number. I think that using session it's the best solution, or no? I wrote next code, which changes do you suggest to improve my code?
Thank you!
<?php
session_start();
$db_host = ...;
$db_user = ...;
$db_password = ...;
$db_name = ...;
$dbms = mysql_connect($db_host, $db_user, $db_password) or die ("It is not possible to connect to server MySql!\n");
$db = mysql_select_db($db_name, $dbms) or die ("It is not possibile to open database db_name!\n");
if (!isset($_COOKIE['PHPSESSID'])) {
mysql_open($dbms, $db);
$visit = "INSERT INTO visits (ip_address, language, browser)
VALUES ('$_SERVER[HTTP_HOST]', '$_SERVER[HTTP_ACCEPT_LANGUAGE]', '$_SERVER[HTTP_USER_AGENT]')";
mysql_query($visit) or die (mysql_error());
mysql_close($dbms);
}
?>