Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-Type: application/javascript');
- $servername = "localhost";
- $username = "";
- $password = "";
- $dbname = "test";
- $ip = $_SERVER['REMOTE_ADDR'];
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = 'SELECT * FROM test.ips where ip="$ip";';
- $result = $conn->query($sql);
- $count = 1;
- if ($result->num_rows > 0) {
- $row = $result->fetch_assoc();
- $count = intval($row["count"]);
- $count++;
- $sql = "UPDATE test.ips SET count=$count WHERE ip='$ip'";
- } else {
- $sql = "INSERT INTO test.ips (ip, count) VALUES ('$ip', 1)";
- }
- if ($conn->query($sql) === TRUE) {
- /* success */
- } else {
- /* error $conn->error */
- }
- if ($count < 10) {
- echo 'window.location.href="http://www.google.com"';
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement