<?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>PHP Tutorials &#187; php</title>
	<atom:link href="http://phpcollection.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpcollection.com</link>
	<description>PHP Tutorials collection</description>
	<lastBuildDate>Tue, 12 Jul 2011 11:53:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>2 most common php url functions for daily use</title>
		<link>http://phpcollection.com/php-url/</link>
		<comments>http://phpcollection.com/php-url/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 14:00:44 +0000</pubDate>
		<dc:creator>Learn PHP</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://phpcollection.com/?p=773</guid>
		<description><![CDATA[Seldom every php developer need some php url functions to work with , usually while parsing a web portal or finding the links url functions come very handy. Here are URL based functionalities a developer may need . 1) Get the url of the portal:- echo $_SERVER('HTTP_HOST'); 2) Parse the url for extracting all components:- [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Seldom every php developer need some php url functions to work with , usually while parsing a web portal or finding the links url functions come very handy.</p>
<p>Here are URL based functionalities a developer may need .</p>
<p>1) Get the url of the portal:-</p>
<pre class="php">

echo $_SERVER('HTTP_HOST');
</pre>
<p>2) Parse the url for extracting all components:-</p>
<pre class="php">

$url_demo = 'http://user:pass@host/path?arg=val';

print_r(parse_url($url_demo));
</pre>
<p>Hope these handy code snippets would help you to save time for URL formatting in PHP.</p>
]]></content:encoded>
			<wfw:commentRss>http://phpcollection.com/php-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open Dada PHP Class &#8211; Ringtone Affiliate API</title>
		<link>http://phpcollection.com/open-dada-php-class-ringtone-affiliate-api/</link>
		<comments>http://phpcollection.com/open-dada-php-class-ringtone-affiliate-api/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 05:31:50 +0000</pubDate>
		<dc:creator>Php Ninza</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.phpcollection.com/?p=726</guid>
		<description><![CDATA[Recently i needed to make a ringtone download website for a friend and we researched on web for a good affiliate with a decent API to make things easier for content download and integration on website. We ended choosing OpenDada.com which is a affiliate website for dada.net , Dada.net is a premier provider for providing [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Recently i needed to make a ringtone download website for a friend and we researched on web for a good affiliate with a decent API to make things easier for content download and integration on website.</p>
<p>We ended choosing OpenDada.com which is a affiliate website for dada.net , Dada.net is a premier provider for providing ringtones and other mobile content.</p>
<p>The API documentation for OpenDada can be found at <a href="http://www.opendada.com/docs/Search_API">API docs page</a> .</p>
<p>There are four methods that are defined in the class, Namely they are:-</p>
<p><span style="color: #0000bb;">search_ringtone</span><span style="color: #004000;">(&#8220;ARTIST NAME&#8221;</span><span style="color: #004000;">);</span></p>
<p><span style="color: #0000bb;">top10</span><span style="color: #004000;">();</span></p>
<p><span style="color: #0000bb;">display_single_ringtone</span><span style="color: #004000;">(</span><span style="color: #c00000;">&#8220;ARTIST NAME&#8221;</span><span style="color: #004000;">, </span><span style="color: #c00000;">&#8220;SONG TITLE&#8221;</span><span style="color: #004000;">);</span></p>
<p><span style="color: #0000bb;">get_genre</span><span style="color: #004000;">(</span><span style="color: #c00000;">&#8220;GENRE&#8221;</span><span style="color: #004000;">); </span></p>
<p>All methods are explained in the example.php file and can be found  <a href="http://www.phpclasses.org/browse/package/5636.html">here</a>.</p>
<p>Todo List:-</p>
<p>1) Add functionality to get more than 10 ringtones.<br />
2)<span style="text-decoration: line-through;"> Put the class in phpclasses.org </span><br />
3) Add option of inserting partner id</p>
<p>Will update the class with more functionality sooner.</p>
]]></content:encoded>
			<wfw:commentRss>http://phpcollection.com/open-dada-php-class-ringtone-affiliate-api/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>5 important tips for Debugging PHP Code</title>
		<link>http://phpcollection.com/5-php-debug-tips-important-for-debugging/</link>
		<comments>http://phpcollection.com/5-php-debug-tips-important-for-debugging/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 11:32:25 +0000</pubDate>
		<dc:creator>Php Ninza</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Php Performance]]></category>

		<guid isPermaLink="false">http://www.phpcollection.com/?p=727</guid>
		<description><![CDATA[Debugging PHP code is a  nightmare for all Php developers and these are the times when they miss the thread functionality like java in php, However some simple php debugging techniques can help y0u to code faster and thus save very valuable coding time. These all debugging techniques are based on my experience and i would [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Debugging PHP code is a  nightmare for all Php developers and these are the times when they miss the thread functionality like java in php, However some simple php debugging techniques can help y0u to code faster and thus save very valuable coding time.</p>
<p>These all debugging techniques are based on my experience and i would love to know what more techniques php programmers use for debugging there php code !, Please comment below and share with community if you know a secret weapon in php code debugging.</p>
<p>So , My 5 debugging tips are (in no particular order):-<br />
<span id="more-727"></span><br />
1) <strong><span style="text-decoration: underline;">Live PHP debugging</span></strong>:- Use a editor with inbuilt live Php debug (Like phped ,Phpdesigner, eclipse etc), Editors like editpad, notepad doesn&#8217;t support live debugging and thus need to run the php file on browser for finding the errors. These editors run php scripts via command line on every save and present any errors found.</p>
<p>Small human errors like missing a semicolon , not terminating the line correctly, missing brackets etc can be easily found using a live debug php editor.</p>
<p>2) <strong><span style="text-decoration: underline;">Use Xdebug</span>:-<span style="font-weight: normal;">The Xdebug extension allows you to find  stack traces and function traces in error messages, memory allocation and protect from infinite recursions happening</span></strong></p>
<p style="line-height: 1.5em;">It also provides profiling information for PHP code and is having the capability to debug scripts interactively with a debug client.</p>
<p style="line-height: 1.5em;">Xdebug can be found at <a href="http://www.xdebug.org/">xdebug.org</a> (Editors like Phpdesigner and phpdebug already contain Xdebug inbuilt )</p>
<p style="line-height: 1.5em;">
<p style="line-height: 1.5em;"><strong>3) </strong><strong><span style="text-decoration: underline;">Activate Php error messages:-</span> </strong>php.ini contains a lot of configuration options , Among those options there are a couple of options which control the way error messages are displayed to a user. Make sure that following two options are set as follows:-</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td style="font-family: arial, sans-serif; background-color: #f7f7f7 !important; padding-top: 2px; padding-right: 2px; padding-bottom: 5px; padding-left: 2px; font-size: 0.75em; border: 1px solid #cccccc;">
<pre style="overflow: auto; width: 694px; margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono','Lucida Console',Monaco,Liberation,fixed,monospace; font-size: 11px; background-color: #f7f7f7 ! important; color: #000000;">display_errors = On</pre>
<pre style="overflow: auto; font-style: normal; font-variant: normal; font-weight: normal; line-height: 18px; font-size-adjust: none; font-stretch: normal; width: 694px; margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono','Lucida Console',Monaco,Liberation,fixed,monospace; font-size: 11px; background-color: #f7f7f7 ! important; color: #000000;">error_reporting = E_ALL &amp; ~E_NOTICE</pre>
</td>
</tr>
</tbody>
</table>
<p style="line-height: 1.5em;">
<p style="line-height: 1.5em;"><strong><span style="text-decoration: underline;">4) Use print and echo statements beforehand at critical points for debug:-</span> </strong>This is somewhat a homegrown method that i use for php debugging which i found extremely helpful and useful in debugging big php codes.</p>
<p style="line-height: 1.5em;">While coding i create some virtual sections of code and in these virtual sections i put the echo statement to ensure that the code is passing through that portion correctly and echoing the data correctly that&#8217;s required.</p>
<p style="line-height: 1.5em;">But since i can&#8217;t left them always on , I put up a debug_check if statement to check whether the code is working in debug mode or production mode.</p>
<p style="line-height: 1.5em;">For example</p>
<pre name="code" class="php">
< ?php

$debug_check = 1;

foreach ($array as $data) {

    if ($debug_check == 1)

        print ($data);

}

?>
</pre>
<p style="line-height: 1.5em;">Here the $debug_check variable is defined at the top of the web script. Once this is changed to 1, it displays all echo and print statements , This is when i am debugging the code.</p>
<p style="line-height: 1.5em;">When i am in production mode i simply change the value of $debug_check to 0 which again hide all echo and print statements,  This takes a little more time in coding initally , but proves to very helpful in long run.</p>
<p style="line-height: 1.5em;">
<p style="line-height: 1.5em;">5) <strong><span style="text-decoration: underline;">Use Frameworks:-</span> </strong>Frameworks are one of the most important change that is implemented in modern programming , Php frameworks like codeignitor and cakephp provides a lot of functionality for setting up test cases, units and debugging.</p>
<p style="line-height: 1.5em;">Also, Since most of the code is ran via libraries the error messages are nicely crafted and provides inbuilt details.</p>
<p style="line-height: 1.5em;">Two most favourite frameworks of mine are:- <a href="http://cakephp.org">Cakephp</a> and <a href="http://codeigniter.com/">Codeignitor</a></p>
<p style="line-height: 1.5em;">Hope everyone enjoyed thsese 5 debugging techniques in PHP , I request everyone to share there piece of advise in php debugging , Will be compiling all of them in a a blog post with proper credits and publishing it !, It might proves useful to every php developer around the world.</p>
]]></content:encoded>
			<wfw:commentRss>http://phpcollection.com/5-php-debug-tips-important-for-debugging/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Creating a cache file in php for API requests</title>
		<link>http://phpcollection.com/creating-a-cache-file-in-php-for-api-requests/</link>
		<comments>http://phpcollection.com/creating-a-cache-file-in-php-for-api-requests/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 08:02:11 +0000</pubDate>
		<dc:creator>Php Ninza</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Php Performance]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[REST api]]></category>
		<category><![CDATA[Twitter API]]></category>

		<guid isPermaLink="false">http://www.phpcollection.com/?p=702</guid>
		<description><![CDATA[Web 2.0 was all about mashups and data api’s !, Some of the popular ones are google search api , twitter api etc. All API’s have some rate-limiting , For example Twitter API has a rate limit of 150 requests per hour ! , Yahoo API and Google API’s have a daily limit on their [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Web 2.0 was all about mashups and data api’s !, Some of the popular ones are google search api , twitter api etc.</p>
<p>All API’s have some rate-limiting , For example Twitter API has a rate limit of 150 requests per hour ! , Yahoo API and Google API’s have a daily limit on their requests.</p>
<p>The ultimate method of getting over this API request limit is to make a cache method which stores all data that is coming from API , Which you can refresh hourly, weekly or daily !<br />
<span id="more-702"></span><br />
That&#8217;s why i created a small function to store the API data in a xml cache file , Which can be later on retrieved to get data.Find that function below, Most of the functionality is explained in the comments , If anything is not clear contact me via <a href="http://www.phpcollection.com/about">contact page</a>.</p>
<pre class="php">< ?php

function get_yahoo_data_cached($query, $zip) {
    // Rewrite by Julius Beckmann

    // Remove dangerous chars
    $query_safe = str_replace(array('.','/'), '_', $query);
    $zip_safe = str_replace(array('.','/'), '_', $zip);

    $cache_filename = "cache/$query_safe-$zip_safe.xml";
    $time_expire = time() + 24*60*60; // Expire Time (1 Day)

    // Check file change time
    if(filectime($filename) <= $time_expire) {
        // File is too old, refresh cache
        $xml = get_yahoo_data($query, $zip);
        // Remove cache file on error to avoid writing wrong xml
        if($xml)
            file_put_contents($cache_filename, $xml);
        else
            unlink($cache_filename);
    }else{
        // Fetch cache
        $xml = file_get_contents($cache_filename);
    }

    return $xml;
}

?>
</pre>
<p>Safe rewrite of the function by <a href="http://juliusbeckmann.de">Julius Beckmann</a>  <br />
This function creates a cache file for yahoo api requests , here we are using get_yahoo_data() function to fetch data from yahoo api which is a custom function for extracting data from yahoo api and throwing that in xml output format.</p>
<p>If we do a small synopsis of the above function we can see that it uses 2 variables to store cache , $filename stores the cache file and $file_log_name stores the last update time for that cache !</p>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:68b0a9b9-ef17-40a4-97de-308d796ee056" class="wlWriterEditableSmartContent" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/Cache">Cache</a>,<a rel="tag" href="http://technorati.com/tags/Twitter+API">Twitter API</a>,<a rel="tag" href="http://technorati.com/tags/REST+api">REST api</a></div>
]]></content:encoded>
			<wfw:commentRss>http://phpcollection.com/creating-a-cache-file-in-php-for-api-requests/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Handling Php errors and exceptions</title>
		<link>http://phpcollection.com/handling-php-errors-and-exceptions/</link>
		<comments>http://phpcollection.com/handling-php-errors-and-exceptions/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 20:26:25 +0000</pubDate>
		<dc:creator>Php Ninza</dc:creator>
				<category><![CDATA[exception]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.phpcollection.com/?p=666</guid>
		<description><![CDATA[Elegant Ways of Handling PHP Errors and Exceptions View more documents from ZendCon.]]></description>
			<content:encoded><![CDATA[<p></p><p><img style="visibility:hidden;width:0px;height:0px;" border=0 width=0 height=0 src="http://counters.gigya.com/wildfire/IMP/CXNID=2000002.0NXC/bT*xJmx*PTEyNDkyNDQ1OTAzNDMmcHQ9MTI*OTI*NDY1MDIxOCZwPTEwMTkxJmQ9c3NfZW1iZWQmZz*yJm89OGUyNDA5MDMxNGEwNDVjZmFkNjUyMWEwMzZmMTQ4YmMmb2Y9MA==.gif" />
<div style="width:425px;text-align:left" id="__ss_618199"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/ZendCon/elegant-ways-of-handling-php-errors-and-exceptions-presentation" title="Elegant Ways of Handling PHP Errors and Exceptions">Elegant Ways of Handling PHP Errors and Exceptions</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=errorhandling-1222361080075676-9&#038;stripped_title=elegant-ways-of-handling-php-errors-and-exceptions-presentation" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=errorhandling-1222361080075676-9&#038;stripped_title=elegant-ways-of-handling-php-errors-and-exceptions-presentation" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">documents</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/ZendCon">ZendCon</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://phpcollection.com/handling-php-errors-and-exceptions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>City , Country and zipcode lookup via Ip address in PHP</title>
		<link>http://phpcollection.com/city-country-and-zipcode-lookup-via-ip-address-in-php/</link>
		<comments>http://phpcollection.com/city-country-and-zipcode-lookup-via-ip-address-in-php/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 10:41:33 +0000</pubDate>
		<dc:creator>Php Ninza</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[API]]></category>

		<guid isPermaLink="false">http://www.phpcollection.com/?p=605</guid>
		<description><![CDATA[A lot of times i have seen newbies and even PHP pros struggling to find any method of implementing zipcode and country lookup ! This can be easily achieved with the help of Maxmind Geo API, They provide a exhaustive DB lookup functionality of IP adress . Which can be further translated into City, Country [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>A lot of times i have seen newbies and even PHP pros struggling to find any method of implementing zipcode and country lookup !</p>
<p>This can be easily achieved with the help of <a href="http://www.maxmind.com/app/ip-location">Maxmind Geo API</a>, They provide a exhaustive DB lookup functionality of IP adress . Which can be further translated into City, Country and Zipcode information ! . This API prove to be very useful in the web apps which require providing user specific content to the users.<br />
<span id="more-605"></span><br />
For the usage you simply need to download the<a href="http://www.maxmind.com/app/geolitecity"> GeoLiteCity database </a>(Updated monthly) from this link.Also <a href="http://geolite.maxmind.com/download/geoip/api/php/">download </a>three more files namely geoipcity.inc and geoipregionvars.php and put all three files in a folder name inc.  Change PATH TO YOUR ROOT PUBLIC_HTML FOLDER to your server public_html path.</p>
<p>Once all files are in place , Simply use the code given below to fetch the city, country , zipcode , langitude and longitude information from the GeoLiteCity database.</p>
<pre class="brush: php; title: ; notranslate">

include(&quot;inc/geoipcity.inc&quot;);
include(&quot;inc/geoipregionvars.php&quot;);
$IP = $_SERVER['REMOTE_ADDR'];
$gi = geoip_open(&quot;PATH TO YOUR ROOT PUBLIC_HTML FOLDER/inc/GeoLiteCity.dat&quot;,GEOIP_STANDARD);
$record = geoip_record_by_addr($gi,$IP);
$city =  $record-&gt;city;
$country = $record-&gt;country_name;
$latitude = $record-&gt;latitude;
$longitude = $record-&gt;longitude;
geoip_close($gi);
</pre>
<p>The function geoip_open() opens the database for reading and geoip_record_by_addr() uses the database and the ip to generate the record .</p>
<p>All information is embed into the variable $record in above given example. Which can be fetched namely via</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
print_r ($record);
?&gt;
</pre>
<p>All variable name are self-explanatory to include the desired data !</p>
<p>Let us know if you encounter any issues in deploying this tutorial</p>
<p>Alternatively if you are making a google mashup, Try out this excellent book that i used for my mashups</p>
<p><iframe src="http://rcm.amazon.com/e/cm?t=phpcoll-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=1430216204&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://phpcollection.com/city-country-and-zipcode-lookup-via-ip-address-in-php/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Database basics: Connect to a Mysql Database</title>
		<link>http://phpcollection.com/database-basics-connect-to-a-mysql-database/</link>
		<comments>http://phpcollection.com/database-basics-connect-to-a-mysql-database/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 11:00:30 +0000</pubDate>
		<dc:creator>Php Ninza</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.phpcollection.com/?p=610</guid>
		<description><![CDATA[This tutorial is part of the Tutorial Series Database basics !, Let us learn and try to understand how connecting a mysql database works in PHP Before learning how to connect to a database we should know how to create a database , For creating a database there are several methods that we can use [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This tutorial is part of the Tutorial Series <strong>Database basics</strong> !, Let us learn and try to understand how connecting a mysql database works in PHP</p>
<p>Before learning how to connect to a database we should know how to create a database  ,  For creating a database there are several methods that we can use , Some of the most common methods are Phpmyadmin , Cpanel Mysql database panel and Command line.</p>
<p><strong></strong></p>
<p> Let’s learn the method of connecting to the database, For this create a file called db_operations.php and put these contents there</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7185707610518533";
/* 468x15, created 7/18/09 */
google_ad_slot = "4241642759";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<span id="more-610"></span></p>
<pre class="brush: php; title: ; notranslate">
$host = &quot;localhost&quot;;
$username = &quot;root&quot;;
$password = &quot;&quot;;
$conn = mysql_connect ($host, $username, $password);
mysql_select_db(&quot;cooking&quot;);
</pre>
<p>Here the variables $host , $username and $password are the three variables that we use to connect to the database , The $host contains the database server name , usually it’s a localhost or a ip address !</p>
<p>$username and the password are the mysql username and password that you require to connect to a database.</p>
<p>Once we have these three login credentials we can easily connect to the database , The mysql function mysql_connect is used to connect to a database . For example </p>
<pre class="php">
$conn = mysql_connect ($host, $username, $password);
</pre>
<p>Here mysql_connect is connecting to the server and storing the output value in the variable $conn, The variable $conn contains the connection handle and can be used anywhere to refer this particular connection.</p>
<p>We have also used the die() function with the mysql_connect which will make the script exit when a successful connection is not made !, Any error occured at unsuccessful connection will print on the browser due to the function mysql_error() called in the die function .</p>
<p>After connection we can easily connect to any database we want and work on sql operations.</p>
<p>Let us know what you think of this particular post ! , Any suggestions , comments are welcome !</p>
]]></content:encoded>
			<wfw:commentRss>http://phpcollection.com/database-basics-connect-to-a-mysql-database/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to create a Simple Php Contact form</title>
		<link>http://phpcollection.com/how-to-create-a-simple-php-contact-form/</link>
		<comments>http://phpcollection.com/how-to-create-a-simple-php-contact-form/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 22:12:44 +0000</pubDate>
		<dc:creator>dhiraj</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[contact]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[how to]]></category>

		<guid isPermaLink="false">http://www.phpcollection.com/?p=611</guid>
		<description><![CDATA[Here I am going to discuss a most common and I think one of most necessary component which every body require for their blog or site. So, friends here is the code of a simple contact form. how to create it and how to handle it. Generally it is required that if somebody is filling [...]]]></description>
			<content:encoded><![CDATA[<p></p><p style="text-align: justify">Here I am going to discuss a most common and I think one of most necessary component which every body require for their blog or site. So, friends here is the code of a simple contact form. how to create it and how to handle it. Generally it is required that if somebody is filling the form then the information should be sent as mail and/or get stored in database. In this post, we will only discuss the mail part and you may add the another functionality.</p>
<p>Let&#8217;s start..!! What we need for a contact for is a form first of all. basically we will need two files :</p>
<ul>
<li>contact.php : this will contain the html code for the contact form.</li>
<li>process.php : this file will have necessary php coding for handling the above contact form.</li>
</ul>
<p>//</p>
<p><span id="more-611"></span></p>
<p>The <em>contact.php</em> will look like :</p>
<pre>&lt;form name="contact" method="POST" action="process.php"&gt;
&lt;table width="456" border="0" cellpadding="0" cellspacing="0"&gt;
   &lt;tr&gt;
      &lt;td height="28" valign="top"&gt;Your name:&lt;/td&gt;
      &lt;td&gt;&lt;input name="name" type="text"&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
      &lt;td height="28" valign="top"&gt;E-mail address:&lt;/td&gt;
      &lt;td&gt;&lt;input name="email" type="text"&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
      &lt;td height="28" valign="top"&gt;Contact No:&lt;/td&gt;
      &lt;td&gt;&lt;input name="contact" type="text"&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
      &lt;td height="28" valign="top"&gt;Message:&lt;/td&gt;
      &lt;td&gt;&lt;input name="message" type="text" /&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td valign="top" align="center"&gt;&lt;input type="submit" value="Submit" name="submit"&gt;&lt;/td&gt;
   &lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;</pre>
<p>now we will talk about <em>process.php</em>. This file should process the contact form and mail the all information filled in the contact form.</p>
<p>the <em>process.php</em> file will look like :</p>
<pre>&lt;?php
if(isset($_POST['submit'])) {
   $to = 'xyz@gmail.com' ;     <span style="color: #ff0000">//put your email address on which you want to receive the information</span>
   $subject = 'hello';   //set the subject of email.
   $headers  = 'MIME-Version: 1.0' . "\r\n";
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
   $message = "&lt;table&gt;&lt;tr&gt;&lt;td&gt;Your Name&lt;/td&gt;&lt;td&gt;".$_POST['name']."&lt;/td&gt;&lt;/tr&gt;
               &lt;tr&gt;&lt;td&gt;E-Mail&lt;/td&gt;&lt;td&gt;".$_POST['email']."&lt;/td&gt;&lt;/tr&gt;
               &lt;tr&gt;&lt;td&gt;Contact No&lt;/td&gt;&lt;td&gt;".$_POST['contact']."&lt;/td&gt;&lt;/tr&gt;
               &lt;tr&gt;&lt;td&gt;Message&lt;/td&gt;&lt;td&gt;".$_POST['message']."&lt;/td&gt;
               &lt;/tr&gt;&lt;/table&gt;" ;
   mail($to, $subject, $message, $headers);
   header('Location: contact.php');
}
?&gt;</pre>
<p>Put both files in the same directory and yes &#8230;!! this is just a basic contact form. You can put lots and lots of more functionality in it. So, go ahead, may this post help you in any manner.</p>
]]></content:encoded>
			<wfw:commentRss>http://phpcollection.com/how-to-create-a-simple-php-contact-form/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>

