<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vincent Reniers &#187; Visitors</title>
	<atom:link href="http://blog.vincentr.be/tag/visitors/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.vincentr.be</link>
	<description>From PHP Guru to Designer!</description>
	<lastBuildDate>Fri, 02 Jul 2010 17:59:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP Tutorial : Log Visitors</title>
		<link>http://blog.vincentr.be/2009/04/19/php-tutorial-log-visitors/</link>
		<comments>http://blog.vincentr.be/2009/04/19/php-tutorial-log-visitors/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 19:48:08 +0000</pubDate>
		<dc:creator>Vincent</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Log]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Visitors]]></category>

		<guid isPermaLink="false">http://vincentr.be/?p=101</guid>
		<description><![CDATA[Today we&#8217;re going to make a simple script that logs all of your visitors and puts it into a database. I will comment every step so you will understand how it works. For newbies who don&#8217;t understand PHP yet check out the first tutorial.
&#60;?php

$mysql_connect = mysql_connect('host', 'user', 'password') or die(&#34;We could not connect to the [...]]]></description>
			<content:encoded><![CDATA[<p>Today we&#8217;re going to make a simple script that logs all of your visitors and puts it into a database. I will comment every step so you will understand how it works. For newbies who don&#8217;t understand PHP yet check out the first tutorial.</p>
<pre class="brush: php;">&lt;?php

$mysql_connect = mysql_connect('host', 'user', 'password') or die(&quot;We could not connect to the MySQL server.&quot;);

// This is simple a connection to the database.
// I'll provide some details on how to construct the table inside the DB later.

$mysql_database = mysql_select('database') or die(&quot;We could not select the database.&quot;);
// Just pick a database where u made your 'visitor' table
// Note: or die(mysql_error()); Is very handy in most cases. It returns a very specific error.
// So now we have the database connection

$user = array();
$user['ip'] = $_SERVER['REMOTE_ADDR'];
$user['browser'] = $_SERVER['HTTP_USER_AGENT'];
$user['page'] = $_SERVER['PHP_SELF'];

// We now create an array and we fill in keys that contain values.
// These values are generated by PHP when a user runs your script (opens a page)
// These values then get put in the $_SERVER array and you can simply fetch them from there.

$insert = mysql_query(&quot;INSERT INTO `visitors` (`ip`,`browser`,`page`)VALUES($user['ip'], $user['browser'], $user['page']) &quot;) or die(mysql_error());
// This query inserts all the information we just gathered into our table.

?&gt;</pre>
<p>Now some info on how to create this table<br />
The table name : visitors<br />
Fields: 4<br />
First field is the : visitor_id  it is the Primary field and it auto increments and an Integer<br />
This means that it simply starts from 0 and always goes up , its a unique id for each field<br />
It helps a lot when you need to select one of these to set an ip to banned for example if you have such a column</p>
<p>Second field : visitor_ip   VARCHAR 255 or something<br />
Third field : browser  VARCHAR 355<br />
Fourth field : page   VARCHAR 35</p>
<p>You can easily set up tables and databases using <a href="http://www.phpmyadmin.net" target="_blank">PHPMyAdmin</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vincentr.be/2009/04/19/php-tutorial-log-visitors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

