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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.