Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-14-2002, 05:12 AM   #1 (permalink)
Britomo
Registered User
 
Join Date: Jul 2002
Location: Essex, England
Posts: 2
Britomo is on a distinguished road
Log visited URL to fileż

I need a php script that will log a visited URL to a file.

For example, if someone visits http://www.mysite.com/user.php?UserName
Then "UserName" is logged to the text file.

I'm completly new to php so I don't even know the term to search for regarding the question mark in the URL (if that makes sense).

Any help on this would be much appreciated
Cheers
Britomo is offline   Reply With Quote
Old 07-14-2002, 09:39 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
hello,

first your url would look more like this when you pass variables with the get method:

http://www.mysite.com/somepage.php?username=mmilano

then you can make a script that reads something like this:

<?
// only run this code if $username exists
if($username)
{

// define the log file
$logfile=log_file_name.txt;

// check to see if the log file exists
if (file_exists($logfile)) {

// open file for append to end and write
$fp = fopen ("$logfile", "aw");

// write the params as name value pairs
fputs ("$username\n");

// close the file
fclose($fp);

}

}
?>

make sure the directory of the log file is set to "world write" or chmod 666

let us know how it went, .. good luck

btw. here is the a good link. php.net is your friend =)
http://www.php.net/manual/en/function.fwrite.php

Last edited by sde; 07-14-2002 at 09:42 AM.
sde is offline   Reply With Quote
Old 07-14-2002, 03:06 PM   #3 (permalink)
Britomo
Registered User
 
Join Date: Jul 2002
Location: Essex, England
Posts: 2
Britomo is on a distinguished road
Yep, that's just what I was looking for :rock:

Cheers mmilano
Britomo is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 04:56 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting