Jump to content

referer url


corillo181

Recommended Posts

why every thing is set into the table but not the refere url... i got this code in all the pages.

<?php
$reff=$_SERVER['HTTP_REFERER'];
if(!isset($_SESSION['online'])){
mysql_query("INSERT INTO online(session_id,activity, ip_address, refurl, user_agent)VALUES('".session_id()."','now()','".$_SERVER['REMOTE_ADDR']."','".$reff."','".$_SERVER['HTTP_USER_AGENT']."')");

$_SESSION['online']="online";

}else{
    
if(isset($_SESSION['user_id'])){

@mysql_query("UPDATE online SET activity=now(), member='y' WHERE session_id='".session_id()."'");
    } 
}

if(isset($_SESSION['online'])){        
@mysql_query("UPDATE online SET activity=now() AND refurl='$reff' WHERE session_id='".session_id()."'");
} ?>
[code]

[/code]

Link to comment
https://forums.phpfreaks.com/topic/57296-referer-url/
Share on other sites

Spelling it right can help:

 

$reff=$_SERVER['HTTP_REFERRER'];

 

Also on a side note, that field may not always be populated or correct as it is sent by the client.

 

Actually the Manuel has it spelled "HTTP_REFERER"

http://www.php.net/manual/en/reserved.variables.php

 

EDIT: Beat to it :P

 

Frost is probably right about it just not being populated. Try echoing to the screen to see if it prints anything.

Link to comment
https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283235
Share on other sites

Try changing this line:

mysql_query("INSERT INTO online(session_id,activity, ip_address, refurl, user_agent)VALUES('".session_id()."','now()','".$_SERVER['REMOTE_ADDR']."','".$reff."','".$_SERVER['HTTP_USER_AGENT']."')");

 

To this:

mysql_query("INSERT INTO online(session_id,activity, ip_address, refurl, user_agent)VALUES('".session_id()."','now()','".$_SERVER['REMOTE_ADDR']."','".$reff."','".$_SERVER['HTTP_USER_AGENT']."')")or die(mysql_eror());

 

What field type do you have the column set to in the database?

Link to comment
https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283241
Share on other sites

The problem is in the update query.

 

<?php
if(isset($_SESSION['online'])){        
mysql_query("UPDATE online SET activity=now(), refurl='$reff' WHERE session_id='".session_id()."'") or die(mysql_error());
} 

 

I highly suggest not using those @ symbols, they screw you up especially when you are trying to fix something that is broken. The update query does not use AND it takes a comma to separate fields.

Link to comment
https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283287
Share on other sites

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.