Jump to content

Problem with code that's suppose to capture user information


andrew_ww

Recommended Posts

Hello,

I have attached some code which when its working is suppose to log various things when a user visits the site (IP, etc..) This script runs without giving an errors, but it does not update anything to database.  When I try to output what its captured the only thng it tells me that I'm localhost.

Does anything look out of place with it ?

-----------------------------
<?php
session_start();

$conn = mysql_connect("localhost", "your-db-login-name", "your-db-password") or die(mysql_error());
mysql_select_db("DATABASE-NAME", $conn) or die(mysql_error());

$sql0 = "select session from getinfo order by id DESC LIMIT 1";
$rslt = mysql_query($sql0) or print("The query: <B>" . $sql . "</B> gave the error <B>" . mysql_error() . "</B>");

if (mysql_num_rows == 1) {

    $session = mysql_result($rslt, 0, 'session');
    if (session_id() != $session) {
        $sql = "insert into getinfo values('', '$_SERVER[REMOTE_ADDR]','".gethostbyaddr($_SERVER[REMOTE_ADDR])."', '$_SERVER[HTTP_REFERER]', now(), '".session_id()."')";
        $query = mysql_query($sql) or print("The query: <B>" . $sql . "</B> gave the error <B>" . mysql_error() . "</B>");
    }
         
} else {

    $sql = "insert into getinfo values('', '$_SERVER[REMOTE_ADDR]','".gethostbyaddr($_SERVER[REMOTE_ADDR])."', '$_SERVER[HTTP_REFERER]', now(), '".session_id()."')";
    $query = mysql_query($sql);

}

$display_block .="
< p>You are visitor number $users.
< p>You are visiting from $host
< p>Your IP address is: $ip";

?>

----------------------------------------------------------

Thanks,

Andy.

[attachment deleted by admin]
From your code snippit I would like to look at the bottom part

[code]
<?php
$display_block .="
< p>You are visitor number $users.
< p>You are visiting from $host
< p>Your IP address is: $ip";

?>
[/code]

I can not see in your script, where you are naming these vars

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.