Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //conectare
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "esticuri_utile";
- //create connection to mysql
- $db_conx_count = mysqli_connect($servername, $username, $password, $dbname);
- $db_conx_count->set_charset('utf8');// pentru diacritice
- if(!$db_conx_count){
- die("Connection failed: ". mysqli_connect_error());
- }
- // gets the user IP Address
- $user_ip = $_SERVER['REMOTE_ADDR'];
- $pagenew = $_SERVER['REQUEST_URI'];
- $check_ip = "select userip from pageview where page='$pagenew' and userip='$user_ip'";
- $query1 = mysqli_query($db_conx_count, $check_ip);
- if (!$check_ip || mysqli_num_rows($check_ip) >= 1)
- {
- }
- else
- {
- $insertview = "insert into pageview values('','$pagenew','$user_ip')";
- $query2 = mysqli_query($db_conx_count, $insertview);
- $updateview = "update totalview set totalvisit=totalvisit + 1 where page='$pagenew' ";
- $query3 = mysqli_query($db_conx_count, $updateview);
- }
- ?>
- <html>
- <head>
- </head>
- <body>
- <?php
- $stmt = "select totalvisit from totalview where page='$pagenew' ";
- $query_stmt = mysqli_query($db_conx_count, $stmt);
- ?>
- <p>This page is viewed <?php echo mysqli_num_rows($query_stmt);?> times.</p>
- <?php mysqli_close($db_conx_count);?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement