Free Webmaster Resources .info
PHP Introduction and Tutorials Javascript  Introduction and Tutorials HTML  Introduction and Tutorials ASP  Introduction and Tutorials Free Internet Access Guide and Directory Webspace  Directory Webhosting  Directory Adult Webhosting  Directory PHP Hosting  Directory ASP Hosting  Directory
à Navigation
» Home
» Php Introduction
» Php Tutorials
» Submit Scripts
 
Subscribe for free!

Join our mailing list today and recieve free updates monthly with web hosting specials!
 
 

 

 

Free Webmaster Resources .info | Free PHP Tutorials


Log Stats in PHP

Welcome to the second part of this mini tutorial / code snippet . Now we will log some info to our MySQL database using PHP .

Here is the script we are using , you will have to input ypour own host , username and password for this to operate correctly.

<?php
//store the users browser in a variable
$users_browser = $HTTP_USER_AGENT;
//store the users IP in a variable
$users_ip = $REMOTE_ADDR;
//database connection
$connection = mysql_connect("localhost" , "username" , "password");
//select the stats database
mysql_select_db("stats" , $connection);
//insert the info into the stats table
$sql_query = "INSERT INTO stats(browser,ip,logdate)
VALUES('$users_browser','$users_ip',now())";
//store
$result = mysql_query($sql_query);
?>

Now all we have to do is test the script works correctly , save the above and call it something like logstats.php , now load this page into your web browser , if you have more than one different make of browser that is even better .

Now go back to MySQL command line and type in the following

SELECT * FROM stats;

In the next part we will show how to display the results in an HTML table in your browser.

[more][1] [2] [3]

Recommended Webhosting Company
Free Web Hosting Info
Get Info on Free Web Hosting from 14 search engines in 1.

 

 
Related Websites
 


Free Email
Your source to free email.

Free Casino Downloads
Contains useful free casino downloads.

Free Software Downloads
A complete collection of free software downloads.

Free
Download free stuff from psike.com your free stuff resource.

Free Teen Online Dating
Meet other singles for free online dating.

Coolfreeweb.com
The Free category at coolfreeweb.com

My Directory Listing
A massive directory listing of websites

Website Collation Project
The website collation project contains a huge directory of websites.


 
Top Webhosts
 
 1. Free Web Hosting Info
 2. With Web Hosting
 3. Find Web Hosting
 4. Web Host
 5. Free Web Hosting
 
-
- Give us feedback
 
Last updated
Jan 03, 2009
Free Webmaster Resources .info | A resource must for every web master
Untitled Document - Web Hosting
- PHP Hosting
- Free Internet Access