View Single Post
  #1 (permalink)  
Old Apr 30th, 2008, 19:32
TheSealPortalTeam's Avatar
TheSealPortalTeam TheSealPortalTeam is offline
User of Users

SuperMember
Join Date: May 2007
Location: Buffalo
Posts: 290
Blog Entries: 15
Thanks: 6
Thanked 1 Time in 1 Post
Record the link you clicked to leave my page

Because My site is a list of web sites and web portals I want to record hits, so when I show you a link to google.com and you click it. I want to record that event with out having google frown on me because I'm redirecting (which I already have a script to do, If i must)

Here is the script I'm using to write the mysql record of the "hit". First thing I need to do is get the URF for the web site then I can write the record.

The site is http://egtworlds.com

PHP: Select all

//This is the include statement that goes on top of the index.php page before a page is declared.
<?php
if (!($HTTP_REFERER) == '') {
include 
"core/pageprocess.php";
}
?>
Here is the real code called "PageProcess.php" it works with a hard coded value and when it is called with out the if statement above, but it doesn't work with the refer value. If thats even the right value.
PHP: Select all

<?php
include 'lang.php'
include_once 
'MySql.php';
$varWebId 0;
$varWebUserIp 0;
$varWebPage '';
$varWebScreenPage '';
$varType 0;
$varHasError 0;
$varWebPageId ='';

$varWebPageId $HTTP_REFERER;
$varWebUserIP $_SERVER['REMOTE_ADDR'];

echo 
$varWebPageId;

$con mysql_connect("localhost","a user name"," a password");                if (!$con)    
    {
        echo 
'Could not connect: ' mysql_error();
    }
            
    If (!
mysql_select_db("a database"$con)) {
        echo 
'Could not process: ' mysql_error();
    }
            
    
$varSqlString "Select * From websites"
    
$varSqlString $varSqlString " where WebPage like '" $varWebPageId  "%'";
    echo     
$varSqlString ;

    
$result mysql_query($varSqlString);
    
$varNumberOfRows mysql_num_rows($result);
    
    
    
    if (
$varNumberOfRows == 0) { 
    
$varHasError 1;
    echo 
'<div class="error"> Your Page could not be accessed</div>';
    
    } elseif (
$varNumberOfRows 1) {
    echo 
'<div class="error"> Your request returned to many websites</div>';
    
$varHasError 1;
    }
    
    while(
$row mysql_fetch_array($result)){
        
$varWebPage $row['WebHomePage'];
        
$varWebScreenPage $row['WebPage'];
        
$varWebPageId =  ($row[0]);
    }
    
mysql_close($con);

    if (
$varHasError == 0) {
    
$strSqlString "INSERT INTO webHits 
        (WebUrfId, WebUserIP) VALUES 
        ('" 
$varWebPageId "', '" $varWebUserIP "')";
    
WriteMySqlRecord($strSqlString);

    }
?>
This would be like Google recording web hits of there search engine. If they can do it, why can't I?
__________________
If I was a big money making person, You wouldn't be here, but You are. (Nothing personal, just a joke!)
EGT Worlds: The funny thing about web portals. Finished!

Last edited by TheSealPortalTeam; Apr 30th, 2008 at 19:35.
Reply With Quote