<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.5" -->
<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/"
	>

<channel>
	<title>Web developers notes,programming tutorials.</title>
	<link>http://developers.chrisranjana.com</link>
	<description>Practical programming advice and development notes</description>
	<pubDate>Tue, 15 Apr 2008 04:56:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>
	<language>en</language>
			<item>
		<title>Custom Validation CCK Custom fields in Drupal</title>
		<link>http://developers.chrisranjana.com/drupal-custom-changes/custom-validation-cck-custom-fields-in-drupal.html</link>
		<comments>http://developers.chrisranjana.com/drupal-custom-changes/custom-validation-cck-custom-fields-in-drupal.html#comments</comments>
		<pubDate>Tue, 15 Apr 2008 04:56:16 +0000</pubDate>
		<dc:creator>malar</dc:creator>
		
		<category>drupal custom changes</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/drupal-custom-changes/custom-validation-cck-custom-fields-in-drupal.html</guid>
		<description><![CDATA[In drupal we can create custom validation for the custom fields created using the CCK module for
content types. We can create a validation wizard or field validation for each content type
seperatly. This requires two modules CCK and CCK_validation.
To add a validation field to a content type, go to administer &#62; content &#62;
content types, select the [...]]]></description>
			<content:encoded><![CDATA[<p>In drupal we can create custom validation for the custom fields created using the CCK module for</p>
<p>content types. We can create a validation wizard or field validation for each content type</p>
<p>seperatly. This requires two modules CCK and CCK_validation.</p>
<p>To add a validation field to a content type, go to administer &gt; content &gt;<br />
content types, select the content type you want to add to, and click on the<br />
&#8216;add field&#8217; tab. One of the field types available should be &#8216;Validation&#8217;, and it<br />
should have one bullet point under it, labelled &#8216;Textarea PHP Code&#8217;. If you select<br />
this, give your field a name, and submit the form, you will get to the<br />
configuration page for your new computed field.</p>
<p>Suppose imagine a content type named &#8220;Book&#8221; and it has custom field &#8220;ISBN&#8221;. In the &#8216;Textarea PHP Code&#8217; of the Validation field we can write a validation code like the one below.</p>
<p>if (!isbn_format($node-&gt;field_text[0][&#8217;value&#8217;])){<br />
form_set_error(&#8217;field_text&#8217;,'The ISBN is not in a valid format.&#8217;);<br />
}</p>
<p>function isbn_format($code)<br />
{</p>
<p>if(!preg_match(&#8221;/[a-zA-Z]/&#8221;,substr($code,0,3),$match))<br />
return false;<br />
if(!is_numeric(substr($code,0,7)))<br />
return false;<br />
return true;<br />
}
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/drupal-custom-changes/custom-validation-cck-custom-fields-in-drupal.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Filter Input</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/filter-input.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/filter-input.html#comments</comments>
		<pubDate>Wed, 09 Apr 2008 01:37:35 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/filter-input.html</guid>
		<description><![CDATA[ Filtering is one of the cornerstones of web application security. It is the process by which you prove the validity of data. By ensuring that all data is properly filtered on input, you can eliminate the risk that tainted (unfiltered) data is mistakenly trusted or misused in your application. The vast majority of security [...]]]></description>
			<content:encoded><![CDATA[<p> Filtering is one of the cornerstones of web application security. It is the process by which you prove the validity of data. By ensuring that all data is properly filtered on input, you can eliminate the risk that tainted (unfiltered) data is mistakenly trusted or misused in your application. The vast majority of security vulnerabilities in popular PHP applications can be traced to a failure to filter input.</p>
<p>When I refer to filtering input, I am really describing three different steps:</p>
<p>    *</p>
<p>      Identifying input<br />
    *</p>
<p>      Filtering input<br />
    *</p>
<p>      Distinguishing between filtered and tainted data</p>
<p>The first step is to identify input because if you don&#8217;t know what it is, you can&#8217;t be sure to filter it. Input is any data that originates from a remote source. For example, anything sent by the client is input, although the client isn&#8217;t the only remote source of dataother examples include database servers and RSS feeds.</p>
<p>Data that originates from the client is easy to identifyPHP provides this data in superglobal arrays, such as $_GET and $_POST. Other input can be more difficult to identifyfor example, $_SERVER contains many elements that can be manipulated by the client. It&#8217;s not always easy to determine which elements in $_SERVER constitute input, so a best practice is to consider this entire array to be input.</p>
<p>What you consider to be input is a matter of opinion in some cases. For example, session data is stored on the server, and you might not consider the session data store to be a remote source. If you take this stance, you can consider the session data store to be an integral part of your application. It is wise to be mindful of the fact that this ties the security of your application to the security of the session data store. This same perspective can be applied to a database because the database can be considered a part of the application as well.</p>
<p>Generally speaking, it is more secure to consider data from session data stores and databases to be input, and this is the approach that I recommend for any critical PHP application.</p>
<p>Once you have identified input, you&#8217;re ready to filter it. Filtering is a somewhat formal term that has many synonyms in common parlancesanitizing, validating, cleaning, and scrubbing. Although some people differentiate slightly between these terms, they all refer to the same processpreventing invalid data from entering your application.</p>
<p>Various approaches are used to filter data, and some are more secure than others. The best approach is to treat filtering as an inspection process. Don&#8217;t correct invalid data in order to be accommodatingforce your users to play by your rules. History has shown that attempts to correct invalid data often create vulnerabilities. For example, consider the following method intended to prevent file traversal (ascending the directory tree):</p>
<p>Can you think of a value of $_POST[&#8217;filename&#8217;] that causes $filename to be ../../etc/passwd? Consider the following:</p>
<p>&#8230;/&#8230;/etc/passwd</p>
<p>This particular error can be corrected by continuing to replace the string until it is no longer found:</p>
<p>Of course, the basename( ) function can replace this entire technique and is a safer way to achieve the desired goal. The important point is that any attempt to correct invalid data can potentially contain an error and allow invalid data to pass through. Inspection is a much safer alternative.</p>
<p>In addition to treating filtering as an inspection process, you want to use a whitelist approach whenever possible. This means that you want to assume the data that you&#8217;re inspecting to be invalid unless you can prove that it is valid. In other words, you want to err on the side of caution. Using this approach, a mistake results in your considering valid data to be invalid. Although undesirable (as any mistake is), this is a much safer alternative than considering invalid data to be valid. By mitigating the damage caused by a mistake, you increase the security of your applications. Although this idea is theoretical in nature, history has proven it to be a very worthwhile approach.</p>
<p>If you can accurately and reliably identify and filter input, your job is almost done. The last step is to employ a naming convention or some other practice that can help you to accurately and reliably distinguish between filtered and tainted data. I recommend a simple naming convention because this can be used in both procedural and object-oriented paradigms. The convention that I use is to store all filtered data in an array called $clean. This allows you to take two important steps that help to prevent the injection of tainted data :</p>
<p>    *</p>
<p>      Always initialize $clean to be an empty array.<br />
    *</p>
<p>      Add logic to detect and prevent any variables from a remote source named clean.</p>
<p>In truth, only the initialization is crucial, but it&#8217;s good to adopt the habit of considering any variable named clean to be one thingyour array of filtered data. This step provides reasonable assurance that $clean contains only data that you knowingly store therein and leaves you with the responsibility of ensuring that you never store tainted data in $clean.</p>
<p>In order to solidify these concepts, consider a simple HTML form that allows a user to select among three colors:</p>
<form action="process.php" method="POST">
<p>Please select a color:</p>
<p>red</p>
<p>green</p>
<p>blue</p>
</form>
<p>In the programming logic that processes this form, it is easy to make the mistake of assuming that only one of the three choices can be provided. As you will learn in the next section, the client can submit any data as the value of $_POST[&#8217;color&#8217;]. To properly filter this data, you can use a switch statement:</p>
<p>This example first initializes $clean to an empty array in order to be certain that it cannot contain tainted data. Once it is proven that the value of $_POST[&#8217;color&#8217;] is one of red, green, or blue, it is stored in $clean[&#8217;color&#8217;]. Therefore, you can use $clean[&#8217;color&#8217;] elsewhere in your code with reasonable assurance that it is valid. Of course, you could add a default case to this switch statement to take a particular action in the case of invalid data. One possibility is to display the form again while noting the errorjust be careful not to output the tainted data in an attempt to be friendly.</p>
<p>While this particular approach is useful for filtering data against a known set of valid values, it does not help you filter data against a known set of valid characters. For example, you might want to assert that a username may contain only alphanumeric characters:</p>
<p>Although a regular expression can be used for this particular purpose, using a native PHP function is always preferable. These functions are less likely to contain errors than code that you write yourself is, and an error in your filtering logic is almost certain to result in a security vulnerability.
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/filter-input.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Create Dynamic Navigation Menus</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/create-dynamic-navigation-menus.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/create-dynamic-navigation-menus.html#comments</comments>
		<pubDate>Thu, 03 Apr 2008 06:57:33 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/create-dynamic-navigation-menus.html</guid>
		<description><![CDATA[Use PHP to build a navigation menu widget that works consistently across your site.
Writing the navigation menu for your site can be a pain. You don&#8217;t want to write the same code over and over on every page. Ideally, you would have a PHP menu function that would render the menu with the current page [...]]]></description>
			<content:encoded><![CDATA[<p>Use PHP to build a navigation menu widget that works consistently across your site.</p>
<p>Writing the navigation menu for your site can be a pain. You don&#8217;t want to write the same code over and over on every page. Ideally, you would have a PHP menu function that would render the menu with the current page highlighted. This hack gives you that simple menu function (for the low cost of this book, no less!).<br />
The Code</p>
<p>Save the code in Example 1, which demonstrates the use of menu.php as index.php.<br />
Example 1. Using the menu library</p>
<table cellpadding="5">
<tr>
<td width="200" valign="top">
</td>
<td width="600" valign="top">
<p>Page: </p>
</td>
</tr>
</table>
<p>Example 2 shows the library, which is surprisingly simple.<br />
Example 2. Making everything work with the PHP library, menu.php</p>
<p>.menu-inactive, .menu-active {</p>
<p>               padding: 2px;</p>
<p>               padding-left: 20px;</p>
<p>               font-family: arial, verdana;</p>
<p>}</p>
<p>.menu-inactive { background: #ddd; }</p>
<p>.menu-active { background: #000; font-weight: bold; }</p>
<p>.menu-inactive a { text-decoration: none; }</p>
<p>.menu-active a { color: white; text-decoration: none; }</p>
<tr>
<td>&#8220;&gt;</p>
<p><a>&#8220;&gt;</p>
<p></a></p>
</td>
</tr>
<table width="100%">
</table>
<p>index.php creates the menu by calling the page_menu function and specifying the page ID. The ID of the page is used to decide which menu item is selected. The index.php script also calls the menu_css function to set up the CSS styles for the menu.</p>
<p>You can change the makeup of the menu by altering the bottom portion of the menu.php file to add or remove menu items. You can also change the look and feel of the menu by altering the CSS class definitions in the menu_css function.
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/create-dynamic-navigation-menus.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Escape Output</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/escape-output.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/escape-output.html#comments</comments>
		<pubDate>Thu, 03 Apr 2008 06:55:30 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/escape-output.html</guid>
		<description><![CDATA[ Another cornerstone of web application security is the practice of escaping outputescaping or encoding special characters so that their original meaning is preserved. For example, O&#8217;Reilly is represented as O\&#8217;Reilly when being sent to a MySQL database. The backslash before the apostrophe is there to preserve itthe apostrophe is part of the data and [...]]]></description>
			<content:encoded><![CDATA[<p> Another cornerstone of web application security is the practice of escaping outputescaping or encoding special characters so that their original meaning is preserved. For example, O&#8217;Reilly is represented as O\&#8217;Reilly when being sent to a MySQL database. The backslash before the apostrophe is there to preserve itthe apostrophe is part of the data and not meant to be interpreted by the database.</p>
<p>As with filtering input, when I refer to escaping output , I am really describing three different steps:</p>
<p>    *</p>
<p>      Identifying output<br />
    *</p>
<p>      Escaping output<br />
    *</p>
<p>      Distinguishing between escaped and unescaped data</p>
<p>To escape output, you must first identify output. In general, this is much easier than identifying input because it relies on an action that you take. For example, to identify output being sent to the client, you can search for strings such as the following in your code:</p>
<p>    *</p>
<p>      echo<br />
    *</p>
<p>      print<br />
    *</p>
<p>      printf<br />
    *</p>
<p>      Welcome back, {$html[&#8217;username&#8217;]}.</p>
<p>&#8220;;</p>
<p>?&gt;
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/escape-output.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Filtering Even Basic Values</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/filtering-even-basic-values.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/filtering-even-basic-values.html#comments</comments>
		<pubDate>Thu, 03 Apr 2008 06:54:04 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/filtering-even-basic-values.html</guid>
		<description><![CDATA[HTML form elements have no types associated with them, and most pass strings (which may represent things such as dates, times, or numbers) to the server. Thus, if you have a numeric field, you cannot assume that it was entered as such. Even in environments where powerful client side code can try to make sure [...]]]></description>
			<content:encoded><![CDATA[<p>HTML form elements have no types associated with them, and most pass strings (which may represent things such as dates, times, or numbers) to the server. Thus, if you have a numeric field, you cannot assume that it was entered as such. Even in environments where powerful client side code can try to make sure that the value entered is of a particular type, there is no guarantee that the values will not be sent to the server directly, as in the &#8220;Double Checking Expected Values&#8221; section.</p>
<p>An easy way to make sure that a value is of the expected type is to cast or convert it to that type and use it, as follows:</p>
<p>$number_of_nights = (int)$_POST[&#8217;num_nights&#8217;];<br />
if ($number_of_nights == 0)<br />
{<br />
 echo &#8220;ERROR: Invalid number of nights for the room!&#8221;;<br />
 exit;<br />
}</p>
<p>If we have the user input a date in a localized format, such as &#8220;mm/dd/yy&#8221;&#8216; for users in the United States, we can then write some code to verify it using the PHP function called checkdate. This function takes a month, day, and year value (4-digit years), and indicates whether or not they form a valid date:</p>
<p>// split is mbcs-safe via mbstring (see chapter 5)<br />
$mmddyy = split($_POST[&#8217;departure_date&#8217;], &#8216;/&#8217;);<br />
if (count($mmddyy) != 3)<br />
{<br />
 echo &#8220;ERROR: Invalid Date specified!&#8221;;<br />
 exit;<br />
}</p>
<p>// handle years like 02 or 95<br />
if ((int)$mmddyy[2]  50)<br />
   $mmddyy[2] = (int)$mmddyy[2] + 1900;<br />
 else if ((int)$mmddyy[2] &gt;= 0)<br />
   $mmddyy[2] = (int)$mmddyy[2] + 2000;</p>
<p> // else it&#8217;s
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/filtering-even-basic-values.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>C# preventing more than one application instance at a time</title>
		<link>http://developers.chrisranjana.com/dot-net-c-development/c-preventing-more-than-one-application-instance-at-a-time.html</link>
		<comments>http://developers.chrisranjana.com/dot-net-c-development/c-preventing-more-than-one-application-instance-at-a-time.html#comments</comments>
		<pubDate>Wed, 02 Apr 2008 10:50:46 +0000</pubDate>
		<dc:creator>monika</dc:creator>
		
		<category>dot net c# development</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/dot-net-c-development/c-preventing-more-than-one-application-instance-at-a-time.html</guid>
		<description><![CDATA[//check if previous instance of the application is already running
//get the name of our process
string proc = Process.GetCurrentProcess().ProcessName;//Get the list of all processes by that name
Process[] processes = Process.GetProcessesByName(proc);//if there is more than one process
if (processes.Length &#62; 1)
{
MessageBox.Show(&#8221;A previous instance of the application is already running&#8221;);
return;
}

]]></description>
			<content:encoded><![CDATA[<p>//check if previous instance of the application is already running</p>
<p>//get the name of our process</p>
<p>string proc = Process.GetCurrentProcess().ProcessName;//Get the list of all processes by that name</p>
<p>Process[] processes = Process.GetProcessesByName(proc);//if there is more than one process</p>
<p>if (processes.Length &gt; 1)</p>
<p>{</p>
<p>MessageBox.Show(&#8221;A previous instance of the application is already running&#8221;);</p>
<p>return;</p>
<p>}
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/dot-net-c-development/c-preventing-more-than-one-application-instance-at-a-time.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Linq with Example in .NET 3.5</title>
		<link>http://developers.chrisranjana.com/dot-net-c-development/linq-with-example-in-net-35.html</link>
		<comments>http://developers.chrisranjana.com/dot-net-c-development/linq-with-example-in-net-35.html#comments</comments>
		<pubDate>Tue, 01 Apr 2008 06:16:14 +0000</pubDate>
		<dc:creator>visa</dc:creator>
		
		<category>dot net c# development</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/dot-net-c-development/linq-with-example-in-net-35.html</guid>
		<description><![CDATA[What is Linq ? 
LINQ stands for Language-Integrated Query is now available as a integral part of Visual Studio.
LINQ has a great power of querying on any source of data, data source could be the collections of objects, database or XML files.We can easily retrieve data from any object that implements the IEnumerable interface. 
Microsoft [...]]]></description>
			<content:encoded><![CDATA[<p>What is Linq ? </p>
<p>LINQ stands for Language-Integrated Query is now available as a integral part of Visual Studio.<br />
LINQ has a great power of querying on any source of data, data source could be the collections of objects, database or XML files.We can easily retrieve data from any object that implements the IEnumerable interface. </p>
<p>Microsoft basically divides LINQ into three areas and that are give below.</p>
<p>1.LINQ to Object {Queries performed against the in-memory data}<br />
2.LINQ to ADO.Net<br />
	= LINQ to SQL<br />
	= LINQ to DataSet<br />
	= LINQ to Entities<br />
3.LINQ to XML </p>
<p>Linq Sample - Where<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>public void Linqsample()<br />
{</p>
<p>int[] numbers = {1,3,2,5,4,7,6,9,8,0};<br />
var findlow = from n in numbers where n
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/dot-net-c-development/linq-with-example-in-net-35.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Semantic URL Attacks</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/semantic-url-attacks.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/semantic-url-attacks.html#comments</comments>
		<pubDate>Fri, 28 Mar 2008 02:22:08 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/semantic-url-attacks.html</guid>
		<description><![CDATA[Curiosity is the motivation behind many attacks, and semantic URL attacks are a perfect example. This type of attack involves the user modifying the URL in order to discover what interesting things can be done. For example, if the user chris clicks a link in your application and arrives at http://example.org/private.php?user=chris, it is reasonable to [...]]]></description>
			<content:encoded><![CDATA[<p>Curiosity is the motivation behind many attacks, and semantic URL attacks are a perfect example. This type of attack involves the user modifying the URL in order to discover what interesting things can be done. For example, if the user chris clicks a link in your application and arrives at http://example.org/private.php?user=chris, it is reasonable to assume that he will try to see what happens when the value for user is changed. For example, he might visit http://example.org/private.php?user=rasmus to see if he can access someone else&#8217;s information. While GET data is only slightly more convenient to manipulate than POST data, its increased exposure makes it a more frequent target, particularly for novice attackers.</p>
<p>Most vulnerabilities exist because of oversight, not because of any particular complexity associated with the exploits. Any experienced developer can easily recognize the danger in trusting a URL in the way just described, but this isn&#8217;t always clear until someone points it out.</p>
<p>To better illustrate a semantic URL attack and how a vulnerability can go unnoticed, consider a web-based email application where users can log in and check their example.org email accounts. Any application that requires its users to log in needs to provide a password reminder mechanism. A common technique for this is to ask the user a question that a random attacker is unlikely to know (the mother&#8217;s maiden name is a common query, but allowing the user to specify a unique question and its answer is better) and email a new password to the email address already stored in the user&#8217;s account.</p>
<p>With a web-based email application, an email address may not already be stored, so a user who answers the verification question may be asked to provide one (the purpose being not only to send the new password to this address, but also to collect an alternative address for future use). The following form asks a user for an alternative email address, and the account name is identified in a hidden form variable:</p>
<form action="reset.php" method="GET">
<p>Please specify the email address where you want your new password sent:</p>
<p></p>
</form>
<p>The receiving script, reset.php, has all of the information it needs to reset the password and send the emailthe name of the account that needs to have its password reset and the email address where the new password is to be sent.</p>
<p>If a user arrives at this form (after answering the verification question correctly), you are reasonably assured that the user is not an imposter but rather the legitimate owner of the chris account. If this user then provides chris@example.org as the alternative email address, he arrives at the following URL after submitting the form:</p>
<p>http://example.org/reset.php?user=chris&amp;email=chris%40example.org</p>
<p>This URL is what appears in the location bar of the browser, so a user who goes through this process can easily identify the purpose of the variables user and email. After recognizing this, the user may decide that php@example.org would be a really cool email address to have, so this same user might visit the following URL as an experiment:</p>
<p>http://example.org/reset.php?user=php&amp;email=chris%40example.org</p>
<p>If reset.php trusts these values provided by the user, it is vulnerable to a semantic URL attack. A new password will be generated for the php account, and it will be sent to chris@example.org, effectively allowing chris to steal the php account.</p>
<p>If sessions are being used to keep track of things, this can be avoided easily:</p>
<p>]+@([-a-z0-9]+\.)+[a-z]{2,}$/i&#8217;;</p>
<p>if (preg_match($email_pattern, $_POST[&#8217;email&#8217;]))</p>
<p>{</p>
<p>$clean[&#8217;email&#8217;] = $_POST[&#8217;email&#8217;];</p>
<p>$user = $_SESSION[&#8217;user&#8217;];</p>
<p>$new_password = md5(uniqid(rand(), TRUE));</p>
<p>if ($_SESSION[&#8217;verified&#8217;])</p>
<p>{</p>
<p>/* Update Password */</p>
<p>mail($clean[&#8217;email&#8217;], &#8216;Your New Password&#8217;, $new_password);</p>
<p>}</p>
<p>}</p>
<p>?&gt;</p>
<p>Although this example omits some realistic details (such as a more complete email message or a more reasonable password), it demonstrates a lack of trust given to the email address provided by the user and, more importantly, session variables that keep up with whether the current user has already answered the verification question correctly ($_SESSION[&#8217;verified&#8217;]) and the name of the account for which the verification question was answered ($_SESSION[&#8217;user&#8217;]). It is this lack of trust given to input that is the key to preventing such gaping holes in your applications
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/semantic-url-attacks.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>7 things to look for in a URL snipping Service</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/7-things-to-look-for-in-a-url-snipping-service.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/7-things-to-look-for-in-a-url-snipping-service.html#comments</comments>
		<pubDate>Fri, 28 Mar 2008 02:19:28 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/7-things-to-look-for-in-a-url-snipping-service.html</guid>
		<description><![CDATA[ 7 things to look for in a URL snipping Service
By Charles H Smith
URL snipping services are becoming commonplace today. Surfers use them to mask affiliate URLs, shorten very long URL&#8217;s, even to hide email addresses from spammers and automatic email harvesters. Ther are several URL snipping services that are no longer active. These inculde: [...]]]></description>
			<content:encoded><![CDATA[<p> 7 things to look for in a URL snipping Service</p>
<p>By Charles H Smith</p>
<p>URL snipping services are becoming commonplace today. Surfers use them to mask affiliate URLs, shorten very long URL&#8217;s, even to hide email addresses from spammers and automatic email harvesters. Ther are several URL snipping services that are no longer active. These inculde: shortlink.us, quickones.org, smlnk.com, and smurl.it. Hopefully, you didn&#8217;t lose any carefully crafted and well planned email link campaigns as these services closed.</p>
<p>As you look to snip your URL&#8217;s using a free service, there are several items to investgate.</p>
<p>First, do the links expire? If they expire, you may want to look to another service.</p>
<p>Second, is there a direct redirect? If, upon selecting the short URL, you are sent to a transition or intersitial page, this page may change in the future to display an advertisment of the free service. The preferable redirection is a direct link to your short URL.</p>
<p>Third, the service should check the URL and determine is is valid. Everyone makes typos, this simply check for valid URL format.</p>
<p>Fourth, how long has the service been in business? Longevity and reliability are crucial when you are snipping hundreds of affiliate links.</p>
<p>Fifth, is there any Terms of Service that you do not agree with? If there are, look for another service.</p>
<p>Sixth, can you use the URL snipping service to hide email addresses from spammers? Try to snip mailto:youremailaddress@yourdomain.com. If the resulting snipped URL opens your default email program, then you may hide your email address from spammers.</p>
<p>Seventh, are your links available only to the site administrators or are they available to the general public?</p>
<p>An alternative to the free services is your own snipping service, running from your server. This ensures your links are available until you decide to delete them.</p>
<p>Generally speaking, the short URL generators are php/MySQL driven scripts. You would need php installed on your server, your site administrator could tell you if it is. You would also need a MySQL database, again your site administrator could tell you if this is available to you.</p>
<p>Another item to check is the control panel page. It should be a php template that can be edited for color, position etc.</p>
<p>If you are using a shared hosting situation you may not be able to run a script that requires will not allow Mod Rewrites to be on, It should be a webmaster settable configuration.</p>
<p>What&#8217;s the difference Mod Rewrites On/Off? As you compare the resulting snipped URL&#8217;s, if has a ? in the URL; such as, http://snippedurl.com/?a then the script is set for Mon Rewrites off. This is probably not the preferable URL format. If there is no ? in the snipped URL then it may only be run with Mod Rewrites on.</p>
<p>As you look to snipping your URL&#8217;s you may want to bring the service in-house to your server. This will give your site added stickyness as your customers, return time and time again to snip their URL&#8217;s.
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/7-things-to-look-for-in-a-url-snipping-service.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Visitor IP Banning</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/visitor-ip-banning.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/visitor-ip-banning.html#comments</comments>
		<pubDate>Fri, 28 Mar 2008 02:17:14 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/visitor-ip-banning.html</guid>
		<description><![CDATA[The below .htaccess code to ban visitor(s) from your site based on their IP address.
Add the below code to your .htaccess file, and upload to root of the  directory: 
## USER IP BANNING
 order allow,deny
 deny from 61.11.74.206          //(it&#8217;s our IP address)
 allow from all
]]></description>
			<content:encoded><![CDATA[<p>The below .htaccess code to ban visitor(s) from your site based on their IP address.</p>
<p>Add the below code to your .htaccess file, and upload to root of the  directory: </p>
<p>## USER IP BANNING</p>
<p> order allow,deny<br />
 deny from 61.11.74.206          //(it&#8217;s our IP address)<br />
 allow from all</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/visitor-ip-banning.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Add Tabs to Your Web Interface Using PHP and CSS</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/add-tabs-to-your-web-interface-using-php-and-css.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/add-tabs-to-your-web-interface-using-php-and-css.html#comments</comments>
		<pubDate>Fri, 28 Mar 2008 02:16:48 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/add-tabs-to-your-web-interface-using-php-and-css.html</guid>
		<description><![CDATA[Use HTML and CSS to create a tabbed interface for your web application.
Sometimes there is just too much data to put onto one web page. An easy way to break up a site (or even a content-heavy page) is to display it using tabs, where the data is broken up into subelements, each correlating to [...]]]></description>
			<content:encoded><![CDATA[<p>Use HTML and CSS to create a tabbed interface for your web application.</p>
<p>Sometimes there is just too much data to put onto one web page. An easy way to break up a site (or even a content-heavy page) is to display it using tabs, where the data is broken up into subelements, each correlating to a named tab. Lucky for us, tabs are a piece of cake with PHP.<br />
The Code</p>
<p>Save the code in Example 1 as index.php.<br />
Example 1. Using the tabs library to show a tabbed interface</p>
<div>
<p>This is the first tab.</p>
<p>This is the second tab.</p>
</div>
<p>Next, code up a nice PHP and CSS library. Save the code in Example 2 as tabs.php.<br />
Example 2. Using PHP and some CSS to create user-friendly tabs</p>
<p>.tab {</p>
<p>border-bottom: 1px solid black;</p>
<p>text-align: center;</p>
<p>font-family: arial, verdana;</p>
<p>}</p>
<p>.tab-active {</p>
<p>border-left: 1px solid black;</p>
<p>border-top: 1px solid black;</p>
<p>border-right: 1px solid black;</p>
<p>text-align: center;</p>
<p>font-family: arial, verdana;</p>
<p>font-weight: bold;</p>
<p>}</p>
<p>.tab-content {</p>
<p>padding: 5px;</p>
<p>border-left: 1px solid black;</p>
<p>border-right: 1px solid black;</p>
<p>border-bottom: 1px solid black;</p>
<p>}</p>
<p> 0 )</p>
<p>endtab();</p>
<p>$tabs []= array(</p>
<p>title =&gt; $title,</p>
<p>text =&gt; &#8220;&#8221;</p>
<p>);</p>
<p>}</p>
<p>function tabs_end( )<br />
{</p>
<p>global $tabs;</p>
<p>endtab( );</p>
<p>ob_end_clean( );</p>
<p>$index = 0;</p>
<p>if ( $_GET[&#8217;tabindex&#8217;] )</p>
<p>$index = $_GET[&#8217;tabindex&#8217;];</p>
<p>?&gt;</p>
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td>&#8220;&gt;</p>
<p><a>&#8220;&gt;</p>
<p></a></p>
</td>
</tr>
<tr>
<td>&#8220;&gt;</p>
</td>
</tr>
</table>
<p>I designed the API on this tabs system to make it easy to create tabs in your document. It starts with invoking tabs_header in the header section of the document. This will set up the CSS for the tabs. Then, within the body, the call to tabs_start sets up the tab system. Each new tab starts with a call to tab with the name of the tab. The call to tabs_end then ends the construction of the tabs.</p>
<p>Internally, the tabs system uses output buffering to hold onto the contents of each tab, and to display whichever tab is selected &#8220;on top.&#8221;
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/add-tabs-to-your-web-interface-using-php-and-css.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Implementing MVC in PHP</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/implementing-mvc-in-php.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/implementing-mvc-in-php.html#comments</comments>
		<pubDate>Thu, 27 Mar 2008 00:50:05 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/implementing-mvc-in-php.html</guid>
		<description><![CDATA[The Controller
Quite simply, the controller handles incoming requests. It uses input, in this case from the URI, to load a module and refresh/render the presentation layer. The controller for the aptly named Framework 1.0 uses a few GET arguments to figure out which module to load.
Before I get to the code, consider a possible request [...]]]></description>
			<content:encoded><![CDATA[<p>The Controller<br />
Quite simply, the controller handles incoming requests. It uses input, in this case from the URI, to load a module and refresh/render the presentation layer. The controller for the aptly named Framework 1.0 uses a few GET arguments to figure out which module to load.</p>
<p>Before I get to the code, consider a possible request that the controller is going to have to be able to handle.</p>
<p>http://example.com/index.php?module=loginThat looks simple enough. However, seeing that the code now runs inside a framework, things are not as simple as they may seem. Here is a simple list of arguments that the controller understands and what they do.</p>
<p>module defines the basic module that the user is requesting. For instance, you may choose to create a module named users that stores your code for logging in, logging out, and registering.<br />
class defines the actual class the controller will load. For instance, in your users module you might have classes named login, logout, and register. If you don&#8217;t specify a class, the controller will attempt to load one with the same name as the module provided.<br />
event defines which method to run after the controller has authenticated the user. By default, the controller will look for and run the __default() method of your class.<br />
A more complex example of what the controller might handle is:</p>
<p>http://example.com/index.php?module=users&amp;class=loginThis tells the controller to locate the module users, load the class login, and, because there is no event defined, run login::__default().</p>
<p>The code</p>
<p>  * @copyright Joe Stump<br />
  * @license http://www.opensource.org/licenses/gpl-license.php<br />
  * @package Framework<br />
  */</p>
<p>  require_once(&#8217;config.php&#8217;);</p>
<p>  // {{{ __autoload($class)<br />
  /**<br />
  * __autoload<br />
  *<br />
  * Autoload is ran by PHP when it can&#8217;t find a class it is trying to load.<br />
  * By naming our classes intelligently we should be able to load most classes<br />
  * dynamically.<br />
  *<br />
  * @author Joe Stump<br />
  * @param string $class Class name we&#8217;re trying to load<br />
  * @return void<br />
  * @package Framework<br />
  */<br />
  function __autoload($class)<br />
  {<br />
      $file = str_replace(&#8217;_',&#8217;/',substr($class,2)).&#8217;.php&#8217;;<br />
      require_once(FR_BASE_PATH.&#8217;/includes/&#8217;.$file);<br />
  }<br />
  // }}}</p>
<p>  if (isset($_GET[&#8217;module&#8217;])) {<br />
      $module = $_GET[&#8217;module&#8217;];<br />
      if (isset($_GET[&#8217;event&#8217;])) {<br />
          $event = $_GET[&#8217;event&#8217;];<br />
      } else {<br />
          $event = &#8216;__default&#8217;;<br />
      }</p>
<p>      if (isset($_GET[&#8217;class&#8217;])) {<br />
          $class = $_GET[&#8217;class&#8217;];<br />
      } else {<br />
          $class = $module;<br />
      }</p>
<p>      $classFile = FR_BASE_PATH.&#8217;/modules/&#8217;.$module.&#8217;/&#8217;.$class.&#8217;.php&#8217;;<br />
      if (file_exists($classFile)) {<br />
          require_once($classFile);<br />
          if (class_exists($class)) {<br />
              try {<br />
                  $instance = new $class();<br />
                  if (!FR_Module::isValid($instance)) {<br />
                      die(&#8221;Requested module is not a valid framework module!&#8221;);<br />
                  }</p>
<p>                  $instance-&gt;moduleName = $module;<br />
                  if ($instance-&gt;authenticate()) {<br />
                      try {<br />
                          $result = $instance-&gt;$event();<br />
                          if (!PEAR::isError($result)) {<br />
                              $presenter = FR_Presenter::factory(<br />
                                  $instance-&gt;presenter,$instance<br />
                              );</p>
<p>                              if (!PEAR::isError($presenter)) {<br />
                                  $presenter-&gt;display();<br />
                              } else {<br />
                                  die($presenter-&gt;getMessage());<br />
                              }<br />
                          }<br />
                      } catch (Exception $error) {<br />
                          die($error-&gt;getMessage());<br />
                      }<br />
                  } else {<br />
                      die(&#8221;You do not have access to the requested page!&#8221;);<br />
                  }<br />
              } catch (Exception $error) {<br />
                  die($error-&gt;getMessage());<br />
              }<br />
          } else {<br />
              die(&#8221;An valid module for your request was not found&#8221;);<br />
          }<br />
      } else {<br />
          die(&#8221;Could not find: $classFile&#8221;);<br />
      }<br />
  } else {<br />
      die(&#8221;A valid module was not specified&#8221;);<br />
  }</p>
<p>?&gt;After looking over the code, you might notice a few things. Here&#8217;s a walk through the second example URI from above to thoroughly explain things.</p>
<p>1. Include config.php<br />
2. Define the __autoload() function. Because all the classes are named in a structured manner, this function can easily include them when necessary. The __autoload() function is new to PHP 5 and provides a method to load classes dynamically. This eliminates the need to have the controller require every single library needed to function. </p>
<p>3. If there is a module argument, the controller needs to start working on loading the module. The next few lines set up the defaults that I discussed earlier. Once $module, $event, and $class are defined, the controller can move on to loading the module.</p>
<p>4. The next few lines have to do with loading and verifying the requested module and class. The controller loads the module&#8217;s config.php and the class file, which in this example is users/login.php. Next, the controller checks to make sure the required file it needs exists and that the requested class is actually defined. </p>
<p>5. Don&#8217;t blink! On the next line I used the wonders of variable functions to instantiate the module. It&#8217;s very important to note that the controller runs the class&#8217;s constructor before it authenticates the user. Due to the class hierarchy, it would be impossible to authenticate before running the constructor. Also, note that the constructor can throw exceptions, which are new to PHP 5, and the controller will handle them appropriately.<br />
Now that the controller has a class, it runs the inherited method authenticate(), which should return a Boolean value. If the function returns true, then the controller continues running the module&#8217;s event handler; if false, then the controller exits out. This would be a good place for the controller to redirect to a login form.</p>
<p>6. The next few lines run the given event, which for the example is login::__default(). The event handler can either throw an exception or return a PEAR_Error, which tells the controller that something deadly has happened. </p>
<p>7. Finally&#8211;yes, finally&#8211;it loads the presentation layer based on what the class has defined. By default, it uses the FR_Presenter_smarty presentation layer. You may not like Smarty, which is fine. Just create a new presentation class and use that instead. If there isn&#8217;t anything wrong with the requested presentation layer, the controller finally runs the display() method, which does the heavy lifting of rendering the module. Notice how I pass the instance of the module class to the presentation layer. </p>
<p>For being under 100 lines of code, the controller sure does a lot! The beauty of MVC programming is that the controller is dumb to what is going on. Its sole purpose is to do simple validation on the request, load up the request, and hand off everything to the presentation layer to render the request.</p>
<p>Working within this structure can seem somewhat rigid at first, but once you realize how much more quickly you are able to create large applications and leverage the existing code, you can easily work around the perceived rigidity.</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/implementing-mvc-in-php.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Validating a DropDownList in C# Asp.Net</title>
		<link>http://developers.chrisranjana.com/dot-net-c-development/validating-a-dropdownlist-in-c-aspnet.html</link>
		<comments>http://developers.chrisranjana.com/dot-net-c-development/validating-a-dropdownlist-in-c-aspnet.html#comments</comments>
		<pubDate>Wed, 26 Mar 2008 09:23:41 +0000</pubDate>
		<dc:creator>monika</dc:creator>
		
		<category>dot net c# development</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/dot-net-c-development/validating-a-dropdownlist-in-c-aspnet.html</guid>
		<description><![CDATA[Use RequiredFieldValidator and set the initial value to theÂ default starting item in the list.Â Â Â Â Â Â Â Â Â 
&#60;td&#62;
Â Â Â Â Â Â Â  &#60;asp:DropDownList ID=&#8221;ctype&#8221; runat=&#8221;server&#8221;&#62;
Â Â Â Â Â Â Â  &#60;asp:ListItem&#62;Select Credit Card Type&#60;/asp:ListItem&#62;
Â Â Â Â Â Â Â Â Â Â Â  &#60;asp:ListItem&#62;Visa&#60;/asp:ListItem&#62;
Â Â Â Â Â Â Â Â Â Â Â  &#60;asp:ListItem&#62;Amex&#60;/asp:ListItem&#62;
Â Â Â Â Â Â Â Â Â Â Â  &#60;asp:ListItem&#62;MasterCard&#60;/asp:ListItem&#62;
Â Â Â Â Â Â Â Â Â Â Â  &#60;asp:ListItem&#62;Discover&#60;/asp:ListItem&#62;
Â Â Â Â Â Â Â  &#60;/asp:DropDownList&#62;
&#60;asp:RequiredFieldValidator ID=&#8221;RequiredFieldValidator1&#8243; runat=&#8221;server&#8221; ErrorMessage=&#8221;Please Select Card Type&#8221; ControlToValidate=&#8221;ctype&#8221; InitialValue=&#8221;Select Credit Card Type&#8221;&#62;
&#60;/asp:RequiredFieldValidator&#62;
&#60;/td&#62;Â 

]]></description>
			<content:encoded><![CDATA[<p>Use RequiredFieldValidator and set the initial value to theÂ default starting item in the list.Â Â Â Â Â Â Â Â Â <br />
&lt;td&gt;<br />
Â Â Â Â Â Â Â  &lt;asp:DropDownList ID=&#8221;ctype&#8221; runat=&#8221;server&#8221;&gt;<br />
Â Â Â Â Â Â Â  &lt;asp:ListItem&gt;Select Credit Card Type&lt;/asp:ListItem&gt;<br />
Â Â Â Â Â Â Â Â Â Â Â  &lt;asp:ListItem&gt;Visa&lt;/asp:ListItem&gt;<br />
Â Â Â Â Â Â Â Â Â Â Â  &lt;asp:ListItem&gt;Amex&lt;/asp:ListItem&gt;<br />
Â Â Â Â Â Â Â Â Â Â Â  &lt;asp:ListItem&gt;MasterCard&lt;/asp:ListItem&gt;<br />
Â Â Â Â Â Â Â Â Â Â Â  &lt;asp:ListItem&gt;Discover&lt;/asp:ListItem&gt;<br />
Â Â Â Â Â Â Â  &lt;/asp:DropDownList&gt;<br />
&lt;asp:RequiredFieldValidator ID=&#8221;RequiredFieldValidator1&#8243; runat=&#8221;server&#8221; ErrorMessage=&#8221;Please Select Card Type&#8221; ControlToValidate=&#8221;ctype&#8221; InitialValue=&#8221;Select Credit Card Type&#8221;&gt;<br />
&lt;/asp:RequiredFieldValidator&gt;<br />
&lt;/td&gt;Â 
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/dot-net-c-development/validating-a-dropdownlist-in-c-aspnet.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to install and start apache service from command line</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/how-to-install-and-start-apache-service-from-command-line.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/how-to-install-and-start-apache-service-from-command-line.html#comments</comments>
		<pubDate>Tue, 25 Mar 2008 11:01:07 +0000</pubDate>
		<dc:creator>bala</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/how-to-install-and-start-apache-service-from-command-line.html</guid>
		<description><![CDATA[i.To install apache as a service from command line
Syntax:
       1.start-&#62;run-&#62;type cmd-&#62;click ok
       2.Type the root folder path of apache
c:/apache&#62; cd bin
c:/apache&#62;bin&#62;httpd -k install -n &#8220;ServiceName&#8221;
ServiceName will be called &#8216;Apache&#8217;.
ii.To start,stop,restart,shutdown apache service from command line
Syntax:
c:/apache&#62;bin&#62;httpd -k start
c:/apache&#62;bin&#62;httpd -k restart
c:/apache&#62;bin&#62;httpd -k stop
c:/apache&#62;bin&#62;httpd -k shutdown

]]></description>
			<content:encoded><![CDATA[<p>i.To install apache as a service from command line</p>
<p><strong>Syntax:</strong><br />
       1.start-&gt;run-&gt;type cmd-&gt;click ok<br />
       2.Type the root folder path of apache</p>
<p>c:/apache&gt; cd bin<br />
c:/apache&gt;bin&gt;httpd -k install -n &#8220;ServiceName&#8221;</p>
<p>ServiceName will be called &#8216;Apache&#8217;.</p>
<p>ii.To start,stop,restart,shutdown apache service from command line</p>
<p><strong>Syntax:</strong></p>
<p>c:/apache&gt;bin&gt;httpd -k start<br />
c:/apache&gt;bin&gt;httpd -k restart<br />
c:/apache&gt;bin&gt;httpd -k stop<br />
c:/apache&gt;bin&gt;httpd -k shutdown
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/how-to-install-and-start-apache-service-from-command-line.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>TABs Control in ASP.Net Ajax</title>
		<link>http://developers.chrisranjana.com/dot-net-c-development/tabs-control-in-aspnet-ajax.html</link>
		<comments>http://developers.chrisranjana.com/dot-net-c-development/tabs-control-in-aspnet-ajax.html#comments</comments>
		<pubDate>Tue, 25 Mar 2008 01:07:15 +0000</pubDate>
		<dc:creator>vijayanand</dc:creator>
		
		<category>dot net c# development</category>

		<category>asp development</category>

		<category>Ajax samples</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/dot-net-c-development/tabs-control-in-aspnet-ajax.html</guid>
		<description><![CDATA[AJAX - Asynchronous Javascript and XML provides a wide range of reliability in ASP.Net 2.0 evolution.
The AJAX Controls are been provided to enable the developer to create pages will less postback and to increase the productivity.
The AJAX plays a vital role in the recent world and it happens to be the most needed thing in [...]]]></description>
			<content:encoded><![CDATA[<p>AJAX - Asynchronous Javascript and XML provides a wide range of reliability in ASP.Net 2.0 evolution.</p>
<p>The AJAX Controls are been provided to enable the developer to create pages will less postback and to increase the productivity.</p>
<p>The AJAX plays a vital role in the recent world and it happens to be the most needed thing in Web Development.</p>
<p>Here comes a TABContainer Control an AJAX Sample Control for ASP.Net 2.0.</p>
<p><strong>DESCRIPTION</strong></p>
<p>TabContainer is an ASP.NET AJAX Control which creates a set of Tabs that can be used to organize page content. A TabContainer is a host for a number of TabPanel controls. </p>
<p>Each TabPanel defines its HeaderText or HeaderTemplate as well as a ContentTemplate that defines its content. The most recent tab should remain selected after a postback, and the Enabled state of tabs should remain after a postback as well. </p>
<p><strong>TABS CONTAINER PROPERTIES</strong></p>
<p>The TABS CONTAINER is initilaized by the following code.</p>
<p><em></p>
<p>            &#8230;</p>
<p>    /&gt;<br />
</em></p>
<p><strong><br />
TabContainer Properties </strong></p>
<p>ActiveTabChanged (Event) - Fired on the server side when a tab is changed after a postback<br />
OnClientActiveTabChanged - The name of a javascript function to attach to the client-side tabChanged event<br />
CssClass - A css class override used to define a custom look and feel for the tabs. See the Tabs Theming section for more details.<br />
ActiveTabIndex - The first tab to show<br />
Height - sets the height of the body of the tabs (does not include the TabPanel headers)<br />
Width - sets the width of the body of the tabs<br />
ScrollBars - Whether to display scrollbars (None, Horizontal, Vertical, Both, Auto) in the body of the TabContainer </p>
<p><strong>TabPanel Properties</strong> </p>
<p>Enabled - Whether to display the Tab for the TabPanel by default. This can be changed on the client.<br />
OnClientClick - The name of a javascript function to attach to the client-side click event of the tab.<br />
HeaderText - The text to display in the Tab<br />
HeaderTemplate - A TemplateInstance.Single ITemplate to use to render the header<br />
ContentTemplate - A TemplateInstance.Single ITemplate to use to render the body </p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/dot-net-c-development/tabs-control-in-aspnet-ajax.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Zebra PHP Framework - PHP MySQL Database Wrapper Class 1.1.0</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/zebra-php-framework-php-mysql-database-wrapper-class-110.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/zebra-php-framework-php-mysql-database-wrapper-class-110.html#comments</comments>
		<pubDate>Mon, 24 Mar 2008 01:02:05 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/zebra-php-framework-php-mysql-database-wrapper-class-110.html</guid>
		<description><![CDATA[Please consider this a BETA version as no thorough tests have been done yet 
What&#8217;s new in this version:
calling on a fetch method and providing a result resource from a query whos result was taken from cache would send the script in an infinite loop
improved the speed of dlookup() method by adding LIMIT to it [...]]]></description>
			<content:encoded><![CDATA[<p>Please consider this a BETA version as no thorough tests have been done yet </p>
<p>What&#8217;s new in this version:</p>
<p>calling on a fetch method and providing a result resource from a query whos result was taken from cache would send the script in an infinite loop<br />
improved the speed of dlookup() method by adding LIMIT to it - thanks to A.Leeming for suggesting this<br />
added some new methods - close() - alias of mysql_close(), log_debug_info() - which will write debug information to a log file and seek() - alias of mysql_data_seek() wich works seamlessly with cached results (previously users haven&#8217;t had a method for iterating through results of a cached query)<br />
the connect() method now returns the link identifier of the connection, which can be later used for closing the connection with the close() method<br />
some documentation refinements (thanks to Vincent van Daal)<br />
completely rewritten template file and stylesheet<br />
a version with the comments stripped out is also available now to be used by those who need a smaller footprint for the classes they include. the script&#8217;s size is almost 4 times smaller than the original script. remember to rename the script to class.database.php if you want to use it </p>
<p>What&#8217;s this?</p>
<p>This PHP script is a MySQL database access wrapper. It provides a set of methods for interracting with a MySQL databases, from within PHP, easily and securely while providing a fantastic debugger [read more]</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/zebra-php-framework-php-mysql-database-wrapper-class-110.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Zebra Content Management System</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/zebra-content-management-system.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/zebra-content-management-system.html#comments</comments>
		<pubDate>Mon, 24 Mar 2008 01:00:53 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/zebra-content-management-system.html</guid>
		<description><![CDATA[After quite a lot of work (and yet still far from over) I started to actually implement websites using the Zebra Content Management System. 
The Zebra Content Management System is both an API and a Content Management System (CMS) providing users a powerful and ready-made backend (the CMS itself) and developers a powerful API to [...]]]></description>
			<content:encoded><![CDATA[<p>After quite a lot of work (and yet still far from over) I started to actually implement websites using the Zebra Content Management System. </p>
<p>The Zebra Content Management System is both an API and a Content Management System (CMS) providing users a powerful and ready-made backend (the CMS itself) and developers a powerful API to interact with the data from the CMS. This gives the possibility for developers to quickly deploy complex websites without having to bother with coding the administration area of it, while having at disposal a powerful yet simple API to produce the front-end. Because of this, the development time of a standard presentation website can be as short as two days (or even a single day!) without sacrificing anything on the website â€“ on the contrary, because more than 95% of the code and logic that is usually written for a website is already implemented in the APIs, the developers can now focus more to perfectly implement the designs and have more time to test it and make sure itâ€™s W3C compliant. </p>
<p>Bottom line is that you can have your website ready very quickly, complete with registered users management, newsletters module, contact requests management (yes, you can forget about that CRM of yours), multiple language support, articles moderation, files management, image galleries and lots of other things, while everything being very search engine optimized. </p>
<p>The Zebra Content Management System (which uses as foundation the Zebra PHP Component Framework) has a very small footprint â€“ the whole package (including documentation) itâ€™s around 7MB. To run it requires an Apache server, PHP 4.3+ and MySQL 4.1+ </p>
<p>Watch the quick presentation movie to get an idea of what I am talking about. An online demo will follow soon. Also, maybe you can share some of your thoughts with me&#8230; </p>
<p>If youâ€™re interested in having your website done with the Zebra Content Management System please let me know by writing an email to noname at nivelzero dot ro.
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/zebra-content-management-system.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Making labels appear for seconds and automatically disappear</title>
		<link>http://developers.chrisranjana.com/dot-net-c-development/making-labels-appear-for-seconds-and-automatically-disappear.html</link>
		<comments>http://developers.chrisranjana.com/dot-net-c-development/making-labels-appear-for-seconds-and-automatically-disappear.html#comments</comments>
		<pubDate>Thu, 20 Mar 2008 11:06:22 +0000</pubDate>
		<dc:creator>monika</dc:creator>
		
		<category>dot net c# development</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/dot-net-c-development/making-labels-appear-for-seconds-and-automatically-disappear.html</guid>
		<description><![CDATA[in the aspx page
&#60;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221;&#62;
&#60;head id=&#8221;Head1&#8243; runat=&#8221;server&#8221;&#62;
&#60;title&#62;Untitled Page&#60;/title&#62;
&#60;script type=&#8221;text/javascript&#8221;&#62;
function TimeOutFuc()
{
var t = setTimeout(&#8221;ShowLabel()&#8221;,3000);
}
function ShowLabel()
{
var divObj = document.getElementById(&#8217;lbl&#8217;);
divObj.style.display = &#8216;none&#8217;;
}
&#60;/script&#62;
&#60;/head&#62;
&#60;body&#62;
&#60;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&#62;
&#60;div&#62;
&#60;/div&#62;
&#60;div id=&#8221;lbl&#8221; &#62;
&#60;asp:Label ID=&#8221;Label1&#8243; runat=&#8221;server&#8221; &#62;&#60;/asp:Label&#62;
&#60;/div&#62;
&#60;br /&#62;
&#60;asp:Button ID=&#8221;Button1&#8243; runat=&#8221;server&#8221; Text=&#8221;Show Label&#8221; onclick=&#8221;Button1_Click&#8221; /&#62;
&#60;/form&#62;
&#60;/body&#62;
&#60;/html&#62;
In the code behind page
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = &#8220;Some Message&#8221;;
Page.RegisterStartupScript(&#8221;ShowLbl&#8221;, &#8220;&#60;script&#62;TimeOutFuc();&#60;/script&#62;&#8221;);
}

]]></description>
			<content:encoded><![CDATA[<p>in the aspx page</p>
<p><em>&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221;&gt;<br />
&lt;head id=&#8221;Head1&#8243; runat=&#8221;server&#8221;&gt;<br />
&lt;title&gt;Untitled Page&lt;/title&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
function TimeOutFuc()<br />
{<br />
var t = setTimeout(&#8221;ShowLabel()&#8221;,3000);<br />
}<br />
function ShowLabel()<br />
{<br />
var divObj = document.getElementById(&#8217;lbl&#8217;);<br />
divObj.style.display = &#8216;none&#8217;;<br />
}<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&gt;<br />
&lt;div&gt;</em></p>
<p><em>&lt;/div&gt;<br />
&lt;div id=&#8221;lbl&#8221; &gt;<br />
&lt;asp:Label ID=&#8221;Label1&#8243; runat=&#8221;server&#8221; &gt;&lt;/asp:Label&gt;<br />
&lt;/div&gt;<br />
&lt;br /&gt;<br />
&lt;asp:Button ID=&#8221;Button1&#8243; runat=&#8221;server&#8221; Text=&#8221;Show Label&#8221; onclick=&#8221;Button1_Click&#8221; /&gt;<br />
&lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</em></p>
<p>In the code behind page</p>
<p><em>protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
Label1.Text = &#8220;Some Message&#8221;;<br />
Page.RegisterStartupScript(&#8221;ShowLbl&#8221;, &#8220;&lt;script&gt;TimeOutFuc();&lt;/script&gt;&#8221;);<br />
}</em>
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/dot-net-c-development/making-labels-appear-for-seconds-and-automatically-disappear.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Color Change onClick</title>
		<link>http://developers.chrisranjana.com/javascripts/color-change-onclick.html</link>
		<comments>http://developers.chrisranjana.com/javascripts/color-change-onclick.html#comments</comments>
		<pubDate>Wed, 19 Mar 2008 11:21:36 +0000</pubDate>
		<dc:creator>malar</dc:creator>
		
		<category>Javascripts</category>

		<category>Html tags and issues</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/javascripts/color-change-onclick.html</guid>
		<description><![CDATA[This a code sniplet for showing a shirt size selection by color change on mouse click in the size
&#60;script language=&#8221;javascript&#8221;&#62;
function set_selection(divid) {
document.getElementById(divid).style.backgroundColor = &#8220;red&#8221;;
document.getElementById(divid).style.color = &#8220;white&#8221;;
for(i=1;i&#60;6;i++) {
if(i != divid) {
document.getElementById(i).style.backgroundColor = &#8220;white&#8221;; document.getElementById(i).style.color = &#8220;black&#8221;; }
}
} &#60;/script&#62;
&#60;table&#62;
&#60;tr&#62; &#60;th colspan=&#8221;5&#8243;&#62;Select your Shirt Size&#60;/th&#62; &#60;/tr&#62;
&#60;tr&#62;
&#60;td&#62;&#60;div id=1 onclick=&#8221;set_selection(1)&#8221; style=&#8221;border: solid black 1px;width:35px;text-align:center&#8221;&#62;&#60;b&#62;S&#60;/div&#62;&#60;/td&#62;
&#60;td&#62;&#60;div id=2 onclick=&#8221;set_selection(2)&#8221; style=&#8221;border: solid black 1px;width:35px;text-align:center&#8221;&#62;&#60;b&#62;M&#60;/div&#62;&#60;/td&#62;
&#60;td&#62;&#60;div [...]]]></description>
			<content:encoded><![CDATA[<p>This a code sniplet for showing a shirt size selection by color change on mouse click in the size</p>
<p>&lt;script language=&#8221;javascript&#8221;&gt;</p>
<p>function set_selection(divid) {</p>
<p>document.getElementById(divid).style.backgroundColor = &#8220;red&#8221;;</p>
<p>document.getElementById(divid).style.color = &#8220;white&#8221;;</p>
<p>for(i=1;i&lt;6;i++) {</p>
<p>if(i != divid) {</p>
<p>document.getElementById(i).style.backgroundColor = &#8220;white&#8221;; document.getElementById(i).style.color = &#8220;black&#8221;; }</p>
<p>}</p>
<p>} &lt;/script&gt;</p>
<p>&lt;table&gt;</p>
<p>&lt;tr&gt; &lt;th colspan=&#8221;5&#8243;&gt;Select your Shirt Size&lt;/th&gt; &lt;/tr&gt;</p>
<p>&lt;tr&gt;</p>
<p>&lt;td&gt;&lt;div id=1 onclick=&#8221;set_selection(1)&#8221; style=&#8221;border: solid black 1px;width:35px;text-align:center&#8221;&gt;&lt;b&gt;S&lt;/div&gt;&lt;/td&gt;</p>
<p>&lt;td&gt;&lt;div id=2 onclick=&#8221;set_selection(2)&#8221; style=&#8221;border: solid black 1px;width:35px;text-align:center&#8221;&gt;&lt;b&gt;M&lt;/div&gt;&lt;/td&gt;</p>
<p>&lt;td&gt;&lt;div id=3 onclick=&#8221;set_selection(3)&#8221; style=&#8221;border: solid black 1px;width:35px;text-align:center&#8221;&gt;&lt;b&gt;L&lt;/div&gt;&lt;/td&gt;</p>
<p>&lt;td&gt;&lt;div id=4 onclick=&#8221;set_selection(4)&#8221; style=&#8221;border: solid black 1px;width:35px;text-align:center&#8221;&gt;&lt;b&gt;XL&lt;/div&gt;&lt;/td&gt;</p>
<p>&lt;td&gt;&lt;div id=5 onclick=&#8221;set_selection(5)&#8221; style=&#8221;border: solid black 1px;width:35px;text-align:center&#8221;&gt;&lt;b&gt;2XL&lt;/div&gt;&lt;/td&gt; &lt;/tr&gt;</p>
<p>&lt;/table&gt;
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/javascripts/color-change-onclick.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Create Pop-Up Hints</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/create-pop-up-hints.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/create-pop-up-hints.html#comments</comments>
		<pubDate>Wed, 19 Mar 2008 00:50:31 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/create-pop-up-hints.html</guid>
		<description><![CDATA[Use the overLIB library to pop up hints for words on your web page using JavaScript and PHP.
With the overLIB JavaScript library (http://www.bosrup.com/web/overlib/), you can have handy pop-up labels that appear above text on your page. This hack makes it a little easier to create these links by providing a PHP wrapper function to invoke [...]]]></description>
			<content:encoded><![CDATA[<p>Use the overLIB library to pop up hints for words on your web page using JavaScript and PHP.</p>
<p>With the overLIB JavaScript library (http://www.bosrup.com/web/overlib/), you can have handy pop-up labels that appear above text on your page. This hack makes it a little easier to create these links by providing a PHP wrapper function to invoke the library.</p>
<p>The Code<br />
Save the code shown in Example 1 as index.php.</p>
<p>Example 1. A wrapper function that simplifies overLIB use, courtesy of PHP</p>
<p><a href="void(0);"></p>
<p>&#8216;);&#8221; onmouseout=&#8221;return nd();&#8221;&gt;</a></p>
<p><!-- overLIB (c) Erik Bosrup --></p>
<div>
</div>
<p>So this is just a test of popups. Not something interesting about Rabbits also make good pets.&#8217;</p>
<p>); ?&gt;. Because that would just be silly.</p>
<p>You could also put the wrapper function into a PHP library, include that library in your PHP pages, and turn this into a nice, reusable utility function.</p>
<p>Running<br />
Download and unpack the overLIB library into your web server&#8217;s documents directory. Then add in the index.php file and surf to it on your browser. You should see something similar to Figure 1.</p>
<p>Figure 1. The page with the pop-up link</p>
<p>Next, move the mouse over the word rabbits, and you will see the pop up appear, which gives you a little more information about rabbits (as seen in Figure 2).</p>
<p>This pop up can be as elaborate as you like, with images, tables, different fonts, styles, and whatever else you please.
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/create-pop-up-hints.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to Backup and Restore MySQL Databases</title>
		<link>http://developers.chrisranjana.com/mysql-database-development/how-to-backup-and-restore-mysql-databases.html</link>
		<comments>http://developers.chrisranjana.com/mysql-database-development/how-to-backup-and-restore-mysql-databases.html#comments</comments>
		<pubDate>Tue, 18 Mar 2008 10:47:51 +0000</pubDate>
		<dc:creator>nithya</dc:creator>
		
		<category>mysql database development</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/mysql-database-development/how-to-backup-and-restore-mysql-databases.html</guid>
		<description><![CDATA[phpMyAdmin can be used to export or backup MySQL databases easily. phpMyAdmin allows users to save database dump as file or display on screen, which involves exporting SQL statements from the server, and transmitting the data across slower network connection or Internet to userâ€™s computer. This process slow the exporting process, increase database locking time [...]]]></description>
			<content:encoded><![CDATA[<p>phpMyAdmin can be used to export or backup MySQL databases easily. phpMyAdmin allows users to save database dump as file or display on screen, which involves exporting SQL statements from the server, and transmitting the data across slower network connection or Internet to userâ€™s computer. This process slow the exporting process, increase database locking time and thus MySQL unavailability, slow the server and may simply crash the Apache HTTPD server if too many incoming web connections hogging the systemâ€™s resources.</p>
<p>The better way to backup and export MySQL database is by doing the task locally on the server, so that the tablesâ€™ data can be instantly dumped on the local disk without delay. Thus export speed will be faster and reduce the time MySQL database or table is locked for accessing. This tutorial is the guide on how to backup (export) and restore (import) MySQL database(s) on the database server itself by using the mysqldump and mysql utilities. There are basically two methods to backup MySQL, one is by copying all table files (*.frm, *.MYD, and *.MYI files) or by using mysqlhotcopy utility, but it only works for MyISAM tables. Below tutorial will concentrate on mysqldump which works for both MyISAM and InnoDB tables.</p>
<p><strong>How to Export or Backup or Dump A MySQL Database</strong></p>
<p>To export a MySQL database into a dump file, simply type the following command syntax in the shell. You can use Telnet or SSH to remotely login to the machine if you donâ€™t have access to the physical box.</p>
<p>mysqldump -u username -ppassword database_name &gt; dump.sql</p>
<p>Replace username with a valid MySQL user ID, password with the valid password for the user (IMPORTANT: no space after -p and the password, else mysqldump will prompt you for password yet will treat the password as database name, so the backup will fail) and database_name with the actual name of the database you want to export. Finally, you can put whatever name you like for the output SQL dump file, here been dump.sql.</p>
<p>The while data, tables, structures and database of database_name will be backed up into a SQL text file named dump.sql with the above command.</p>
<p><strong>How to Export A MySQL Database Structures Only</strong></p>
<p>If you no longer need the data inside the databaseâ€™s tables (unlikely), simply add â€“no-data switch to export only the tablesâ€™ structures. For example, the syntax is:</p>
<p>mysqldump -u username -ppassword â€“no-data database_name &gt; dump.sql</p>
<p><strong>How to Backup Only Data of a MySQL Database</strong></p>
<p>If you only want the data to be backed up, use â€“no-create-info option. With this setting, the dump will not re-create the database, tables, fields, and other structures when importing. Use this only if you pretty sure that you have a duplicate databases with same structure, where you only need to refresh the data.</p>
<p>mysqldump -u username -ppassword â€“no-create-info database_name &gt; dump.sql</p>
<p>How to Dump Several MySQL Databases into Text File</p>
<p>â€“databases option allows you to specify more than 1 database. Example syntax:</p>
<p>mysqldump -u username -ppassword â€“databases db_name1 [db_name2 â€¦] &gt; dump.sql</p>
<p><strong>How to Dump All Databases in MySQL Server</strong></p>
<p>To dump all databases, use the â€“all-databases option, and no databasesâ€™ name need to be specified anymore.</p>
<p>mysqldump -u username -ppassword â€“all-databases &gt; dump.sql</p>
<p><strong>How to Online Backup InnoDB Tables</strong></p>
<p>Backup the database inevitable cause MySQL server unavailable to applications because when exporting, all tables acquired a global read lock using FLUSH TABLES WITH READ LOCK at the beginning of the dump until finish. So although READ statements can proceed, all INSERT, UPDATE and DELETE statements will have to queue due to locked tables, as if MySQL is down or stalled. If youâ€™re using InnoDB, â€“single-transaction is the way to minimize this locking time duration to almost non-existent as if performing an online backup. It works by reading the binary log coordinates as soon as the lock has been acquired, and lock is then immediately released.</p>
<p><strong>Syntax:</strong></p>
<p>mysqldump -u username -ppassword â€“all-databases â€“single-transaction &gt; dump.sql</p>
<p><strong>How to Restore and Import MySQL Database</strong></p>
<p>You can restore from phpMyAdmin, using Import tab. For faster way, upload the dump file to the MySQL server, and use the following command to import the databases back into the MySQL server.</p>
<p>mysql -u username -ppassword database_name
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/mysql-database-development/how-to-backup-and-restore-mysql-databases.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>how to restore backup file in mysql command line</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/how-to-restore-backup-file-in-mysql-command-line.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/how-to-restore-backup-file-in-mysql-command-line.html#comments</comments>
		<pubDate>Tue, 18 Mar 2008 10:13:29 +0000</pubDate>
		<dc:creator>bala</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/how-to-restore-backup-file-in-mysql-command-line.html</guid>
		<description><![CDATA[1.To restore a backup file into the mysql database
Syntax: 
mysql -u [username] -p[password] [datebase_name] &#62; [File_path]
Example:
mysql -u root -p sample &#62; c:/backupfile.sql;
2.To restore a compressed file into the mysql database
Syntax: 
gunzip

]]></description>
			<content:encoded><![CDATA[<p>1.To restore a backup file into the mysql database</p>
<p><strong>Syntax: </strong><br />
mysql -u [username] -p[password] [datebase_name] &gt; [File_path]</p>
<p>Example:<br />
mysql -u root -p sample &gt; c:/backupfile.sql;</p>
<p>2.To restore a compressed file into the mysql database</p>
<p><strong>Syntax: </strong><br />
gunzip
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/how-to-restore-backup-file-in-mysql-command-line.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Creating Windows Service in C#</title>
		<link>http://developers.chrisranjana.com/dot-net-c-development/creating-windows-service-in-c.html</link>
		<comments>http://developers.chrisranjana.com/dot-net-c-development/creating-windows-service-in-c.html#comments</comments>
		<pubDate>Tue, 18 Mar 2008 10:04:41 +0000</pubDate>
		<dc:creator>vijayanand</dc:creator>
		
		<category>dot net c# development</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/dot-net-c-development/creating-windows-service-in-c.html</guid>
		<description><![CDATA[ASP .Net Applications runs using Web Services. Similarly we can use Windows Service which will work when the Machine Starts. 
How to Create a Windows Service Step by Step instructions
1. Open the ID Visual C# 2005 Express Edition -  by clicking the menus: [File]-&#62;[New Project], Select &#8220;Empty Project&#8221;, Rename to WindowsService. Click OK to [...]]]></description>
			<content:encoded><![CDATA[<p>ASP .Net Applications runs using Web Services. Similarly we can use Windows Service which will work when the Machine Starts. </p>
<p>How to Create a Windows Service Step by Step instructions</p>
<p>1. Open the ID Visual C# 2005 Express Edition -  by clicking the menus: [File]-&gt;[New Project], Select &#8220;Empty Project&#8221;, Rename to WindowsService. Click OK to create the project.</p>
<p>2. Project is created, and initially, it&#8217;s not saved anywhere but a temporary location, so go ahead and go to [File]-&gt;[Save All], and okay through the dialog. This will officially save the project.</p>
<p>3. Add the System.ServiceProcess and System.Configuration.Install references to your project. In the Solution Explorer, right-click &#8220;References&#8221;, and select &#8220;Add Reference&#8230;&#8221;. In the dialog box that pops up, make sure the &#8220;.NET&#8221; tab is selected, and then scroll down in the list to &#8220;System.ServiceProcess&#8221;, select it, and click OK. You&#8217;ll see a new entry under References. This will allow you to write code that references the System.ServiceProcess classes. Repeat the process to add the System.Configuration.Install reference.</p>
<p>4. Add two new class files to the project, one labeled: &#8220;WindowsService.cs&#8221; and the other: &#8220;WindowsServiceInstaller.cs&#8221;. In the Solution Explorer, right-click the project name and go to: [Add]-&gt;[Class]. Name the class &#8220;WindowsService.cs&#8221; and then hit OK. Repeat the process for &#8220;WindowsServiceInstaller.cs&#8221;. Now you have two brand-new files with the basics.</p>
<p>5. In WindowsService.cs copy the following code</p>
<p><em>using System;<br />
using System.Diagnostics;<br />
using System.ServiceProcess;</p>
<p>namespace WindowsService<br />
{<br />
    class WindowsService : ServiceBase<br />
    {<br />
        ///<br />
        /// Public Constructor for WindowsService.<br />
        /// - Put all of your Initialization code here.<br />
        ///<br />
        public WindowsService()<br />
        {<br />
            this.ServiceName = &#8220;My Windows Service&#8221;;<br />
            this.EventLog.Log = &#8220;Application&#8221;;</p>
<p>            // These Flags set whether or not to handle that specific<br />
            //  type of event. Set to true if you need it, false otherwise.<br />
            this.CanHandlePowerEvent = true;<br />
            this.CanHandleSessionChangeEvent = true;<br />
            this.CanPauseAndContinue = true;<br />
            this.CanShutdown = true;<br />
            this.CanStop = true;<br />
        }</p>
<p>        ///<br />
        /// The Main Thread: This is where your Service is Run.<br />
        ///<br />
        static void Main()<br />
        {<br />
            ServiceBase.Run(new WindowsService());<br />
        }</p>
<p>        ///<br />
        /// Dispose of objects that need it here.<br />
        ///<br />
        /// Whether<br />
        ///    or not disposing is going on.<br />
        protected override void Dispose(bool disposing)<br />
        {<br />
            base.Dispose(disposing);<br />
        }</p>
<p>        ///<br />
        /// OnStart(): Put startup code here<br />
        ///  - Start threads, get inital data, etc.<br />
        ///<br />
        ///<br />
        protected override void OnStart(string[] args)<br />
        {<br />
            base.OnStart(args);<br />
        }</p>
<p>        ///<br />
        /// OnStop(): Put your stop code here<br />
        /// - Stop threads, set final data, etc.<br />
        ///<br />
        protected override void OnStop()<br />
        {<br />
            base.OnStop();<br />
        }</p>
<p>        ///<br />
        /// OnPause: Put your pause code here<br />
        /// - Pause working threads, etc.<br />
        ///<br />
        protected override void OnPause()<br />
        {<br />
            base.OnPause();<br />
        }</p>
<p>        ///<br />
        /// OnContinue(): Put your continue code here<br />
        /// - Un-pause working threads, etc.<br />
        ///<br />
        protected override void OnContinue()<br />
        {<br />
            base.OnContinue();<br />
        }</p>
<p>        ///<br />
        /// OnShutdown(): Called when the System is shutting down<br />
        /// - Put code here when you need special handling<br />
        ///   of code that deals with a system shutdown, such<br />
        ///   as saving special data before shutdown.<br />
        ///<br />
        protected override void OnShutdown()<br />
        {<br />
            base.OnShutdown();<br />
        }</p>
<p>        ///<br />
        /// OnCustomCommand(): If you need to send a command to your<br />
        ///   service without the need for Remoting or Sockets, use<br />
        ///   this method to do custom methods.<br />
        ///<br />
        /// Arbitrary Integer between 128 &amp; 256<br />
        protected override void OnCustomCommand(int command)<br />
        {<br />
            //  A custom command can be sent to a service by using this method:<br />
            //#  int command = 128; //Some Arbitrary number between 128 &amp; 256<br />
            //#  ServiceController sc = new ServiceController(&#8221;NameOfService&#8221;);<br />
            //#  sc.ExecuteCommand(command);</p>
<p>            base.OnCustomCommand(command);<br />
        }</p>
<p>        ///<br />
        /// OnPowerEvent(): Useful for detecting power status changes,<br />
        ///   such as going into Suspend mode or Low Battery for laptops.<br />
        ///<br />
        /// The Power Broadcast Status<br />
        /// (BatteryLow, Suspend, etc.)<br />
        protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus)<br />
        {<br />
            return base.OnPowerEvent(powerStatus);<br />
        }</p>
<p>        ///<br />
        /// OnSessionChange(): To handle a change event<br />
        ///   from a Terminal Server session.<br />
        ///   Useful if you need to determine<br />
        ///   when a user logs in remotely or logs off,<br />
        ///   or when someone logs into the console.<br />
        ///<br />
        /// The Session Change<br />
        /// Event that occured.<br />
        protected override void OnSessionChange(<br />
                  SessionChangeDescription changeDescription)<br />
        {<br />
            base.OnSessionChange(changeDescription);<br />
        }<br />
    }<br />
}<br />
</em></p>
<p>6. In WindowsServiceInstaller.cs copy the following code.</p>
<p><em>using System;<br />
using System.ComponentModel;<br />
using System.Configuration.Install;<br />
using System.ServiceProcess;</p>
<p>namespace WindowsService<br />
{<br />
    [RunInstaller(true)]<br />
    public class WindowsServiceInstaller : Installer<br />
    {<br />
        ///<br />
        /// Public Constructor for WindowsServiceInstaller.<br />
        /// - Put all of your Initialization code here.<br />
        ///<br />
        public WindowsServiceInstaller()<br />
        {<br />
            ServiceProcessInstaller serviceProcessInstaller =<br />
                               new ServiceProcessInstaller();<br />
            ServiceInstaller serviceInstaller = new ServiceInstaller();</p>
<p>            //# Service Account Information<br />
            serviceProcessInstaller.Account = ServiceAccount.LocalSystem;<br />
            serviceProcessInstaller.Username = null;<br />
            serviceProcessInstaller.Password = null;</p>
<p>            //# Service Information<br />
            serviceInstaller.DisplayName = &#8220;My New C# Windows Service&#8221;;<br />
            serviceInstaller.StartType = ServiceStartMode.Automatic;</p>
<p>            //# This must be identical to the WindowsService.ServiceBase name<br />
            //# set in the constructor of WindowsService.cs<br />
            serviceInstaller.ServiceName = &#8220;My Windows Service&#8221;;</p>
<p>            this.Installers.Add(serviceProcessInstaller);<br />
            this.Installers.Add(serviceInstaller);<br />
        }<br />
    }<br />
}</em></p>
<p>7.The ServiceAccount section of the code is important for the security context under which your code will run. For every enumeration except User, set the Username and Password properties to null.</p>
<p>You can set the Account property to the following (this is mostly from Microsoft&#8217;s help file):</p>
<p>The LocalSystem enumeration defines a highly privileged account, but most services do not require such an elevated privilege level.<br />
The LocalService enumeration provides a lower privilege level for the security context.<br />
The NetworkService enumeration provides extensive local privileges, and provides the computer&#8217;s credentials to remote servers.<br />
The User enumeration allows the use of a username and password combination to set the privilege level for the security context to that of a specified user.<br />
There. That wasn&#8217;t so tough! Now, in the WindowsService class, depending on what you&#8217;re creating this service for, you&#8217;ll probably want to include a background working thread to handle, well, the work. I&#8217;ve used this code simply by leaving everything as-is with just the OnCustomCommand method modified, and it works OK. If you wish to handle constant or timed processing, best add at least one working thread.</p>
<p>8. <strong>Installation</strong></p>
<p>To install a service, you could create an installation program that encapsulates the executable for deployment, which I find time consuming and inefficient when testing an application. Or, you could install the service though the InstallUtil.exe process that comes with the .NET Framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/dot-net-c-development/creating-windows-service-in-c.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Creating Search Engine Friendly URLs In PHP</title>
		<link>http://developers.chrisranjana.com/beginners-php-php-novices/creating-search-engine-friendly-urls-in-php.html</link>
		<comments>http://developers.chrisranjana.com/beginners-php-php-novices/creating-search-engine-friendly-urls-in-php.html#comments</comments>
		<pubDate>Tue, 18 Mar 2008 02:18:54 +0000</pubDate>
		<dc:creator>prem</dc:creator>
		
		<category>Beginners Php / Php Novices</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/beginners-php-php-novices/creating-search-engine-friendly-urls-in-php.html</guid>
		<description><![CDATA[Apache&#8217;s Mod Rewrite
The first method we will look at is the mod_rewrite module that comes with Apache. This module works by matching the requested URL against a set of predefined rules, and then passing in the data to the specified script in the format you determine.
Letâ€™s say that we have a script called news.php in [...]]]></description>
			<content:encoded><![CDATA[<p>Apache&#8217;s Mod Rewrite</p>
<p>The first method we will look at is the mod_rewrite module that comes with Apache. This module works by matching the requested URL against a set of predefined rules, and then passing in the data to the specified script in the format you determine.</p>
<p>Letâ€™s say that we have a script called news.php in the root directory of the web site (so you could access via http://www.example.com/news.php). This script is responsible for outputting a single news article, as chosen by the news_id parameter passed in the URL.</p>
<p>So if you were trying the access the new article with an ID of 63, you would use http://www.example.com/news.php?news_id=63.</p>
<p>Instead though, we want to make this a bit fancier, so rather than passing an in the URL, we want to access articles using http://www.example.com/news/63.html. Thereâ€™s no particular reason for having it like this â€“ itâ€™s just for our example.</p>
<p>Anyway, we can make this happen with mod_rewrite with a very simple rule, either in the web server config (httpd.conf), or in a .htaccess file in the web site directory.</p>
<p>The contents would look like this:<br />
Listing 1 .htaccess</p>
<p>RewriteEngine on<br />
RewriteRule ^/news/([0-9]+)\.html /news.php?news_id=$1</p>
<p>Using the above regular expression, we match all requests to the web site that start with news, then have a number followed by .html. Items stored in brackets are stored in variables, such as $1 or $2 (we only have one set of brackets so only $1 is set here).</p>
<p>We then use the $1 parameter in the destination URL. Now inside the news.php script, we just access the news_id parameter as we would have if we called the script in the original way. That is:<br />
Listing 2 news.php</p>
<p>Extra URL parameters</p>
<p>Sometimes you have a situation where you want to pass extra URL parameters to the script. So going back to our example above, perhaps you can access the news.php script with an extra parameter called â€˜printâ€™, which displayed a printer friendly version of the article (technically you should be using CSS stylesheets for this, but that doesnâ€™t matter for this example).</p>
<p>So you would normally access the printer friendly version of article 63 using http://www.example.com/news.php?news_id=63&amp;print=1.</p>
<p>Using our rewrite version, we want to access the article using http://www.example.com/news/63.html?print=1, however, the rule we created above will simply discard the print parameter in the URL. To pass this to the news script, we need to use the internal Apache variable %{QUERY_STRING} in our mod_rewrite pattern. We just append this to the news_id with an ampersand.<br />
Listing 3 .htaccess</p>
<p>RewriteEngine on<br />
RewriteRule ^/news/([0-9]+)\.html /news.php?news_id=$1&amp;%{QUERY_STRING}</p>
<p>So now, we can access both parameters through $_GET.<br />
Listing 4 news.php</p>
<p>So thatâ€™s all there is to using mod_rewrite. This is a very powerful and complex module, and it is easy to get into trouble using it. Sometimes it can be hard to get your patterns to match correctly, or you create recursive rules, etc. There are several debug settings you can use to try and resolve any problems you might have.<br />
Using The Apache Forcetype Directive</p>
<p>An alternative to using mod_rewrite is to instead use the ForceType directive. What this does, is allow PHP scripts without a .php extension to be executed as PHP scripts. Normally web servers are configured so PHP scripts must finish with .php, so other non-PHP scripts (such as .html files) donâ€™t have to be processed by PHP.</p>
<p>Going back to our example in the mod_rewrite section, instead of having a script called news.php in the root directory, our script would just be called news. So it would be accessed using http://www.example.com/news.</p>
<p>Using the following in our httpd.conf or a .htaccess, this news file will processed on the server as a PHP file.<br />
Listing 5 .htaccess</p>
<p>    ForceType application/x-httpd-php</p>
<p>Now, when we access our article using http://www.example.com/news/63.html, our news script is accessed directly, and we must parse out the /63.html part. This is stored in the server variable PATH_INFO.<br />
Listing 6 news</p>
<p>So now we can use regular expressions to extract the number 63 from this string. There are other techniques you will find useful for extracting data also, such as using PHPâ€™s explode() function. For example, if you explode this string on /, then all parts of the path will be stored in an array (thereâ€™s only 1 part in this example though, so itâ€™s not worth doing). Anyway, back to regular expressions.</p>
<p>Here is a regular expression (compatible with preg_match()), that looks for a string that has precisely a slash at the start, then a number, followed by .html. It then stores the matches to an array, from which we extract the article Id.<br />
Listing 7 news</p>
<p>Normally weâ€™d use / as the regex delimeter, but since weâ€™re matching a slash, itâ€™s tidier to use something different (in this case !). Additionally, weâ€™re matching 1 (+) or more digits (\d), and we must escape the . since weâ€™re matching a literal period (. normally means â€œany characterâ€?).</p>
<p>So thatâ€™s all there is to it. Now you can use the $news_id accordingly in that script. Of course, if the path was in an incorrect format, the matched $news_id would come out as 0 after we casted it as an int, so in other words, itâ€™ll still be safe to plugin to your database, even if the article doesnâ€™t exist.<br />
Using A Custom 404 Handler</p>
<p>This is probably the most complicated method of achieving this result, however, it is also the simplest to expand upon and is more powerful.</p>
<p>By taking advantage of Apacheâ€™s custom 404 handler, you can have a single controlling script that decides how all requests are handled. Of course, this is only requests that do not match an existing file. For example, if you have images on your web site, you can still access them in an identical fashion â€” the image file will exist, hence the 404 handler will not be used.</p>
<p>Additionally, by taking advantage of PHPâ€™s header() function, you can output, say, a 200 OK header rather than a 404 File Not Found header, so from the end userâ€™s point of view, they have no idea the page wasnâ€™t really found.<br />
An example of where this would be used</p>
<p>Taking this idea further, you probably wouldnâ€™t bother implementing a system like this for just a news handling engine as in our examples, but rather, on a larger site that has a lot more content.</p>
<p>For example, if you look at the following URL: http://www.phpriot.com/d/articles/php/index.html. PhpRiot is actually using the â€˜ForceTypeâ€™ method with a PHP script called â€˜dâ€™ that handles requests, but we could have implemented it using this method.<br />
Note: This URL was used in a previous version of PhpRiot - the URL scheme of the site no longer works in this fashion.</p>
<p>Suppose we wanted our URL to look like this: http://www.phpriot.com/articles/php/index.html. Instead of creating this path on our web server for each and every article, we would use the 404 handler to parse out the article path like we currently do with our d file.<br />
Implementing the 404 handler</p>
<p>Weâ€™re not going to implement the example listed above as it involves other complexities not relevant to this article, so instead, weâ€™ll implement our news article example. Weâ€™re also going to add in scope to handle other requests (other than news) and also for outputting error pages.</p>
<p>The first thing to do would be to setup the 404 handler. This can be done either in a .htaccess or in the httpd.conf.<br />
Listing 8 .htaccess</p>
<p>ErrorDocument 404 /handler.php</p>
<p>This means that all requests that donâ€™t match an existing file, are passed to the handler.php script in our web root.</p>
<p>So in this script, we need to parse out the request. You can find the original request in the server REDIRECT_URL variable.<br />
Listing 9 handler.php</p>
<p>Obviously this script is slightly crude, but hopefully in its simplicity you can see how powerful this method can be and what possibilities it can open.
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/beginners-php-php-novices/creating-search-engine-friendly-urls-in-php.html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>auto-complete feature using jQuery</title>
		<link>http://developers.chrisranjana.com/javascripts/auto-complete-feature-using-jquery.html</link>
		<comments>http://developers.chrisranjana.com/javascripts/auto-complete-feature-using-jquery.html#comments</comments>
		<pubDate>Tue, 18 Mar 2008 00:52:15 +0000</pubDate>
		<dc:creator>malar</dc:creator>
		
		<category>Javascripts</category>

		<guid isPermaLink="false">http://developers.chrisranjana.com/javascripts/auto-complete-feature-using-jquery.html</guid>
		<description><![CDATA[Here we are going to discuss about implement a auto-complete feature using jQuery
&#60;script type=&#8221;text/javascript&#8221; src=&#8221;jquery.js&#8221; mce_src=&#8221;jquery.js&#8221;&#62;&#60;/script&#62;
&#60;script type=&#8221;text/javascript&#8221; src=&#8221;dimensions.js&#8221; mce_src=&#8221;dimensions.js&#8221;&#62;&#60;/script&#62;
&#60;script type=&#8221;text/javascript&#8221; src=&#8221;autocomplete.js&#8221; mce_src=&#8221;autocomplete.js&#8221;&#62;&#60;/script&#62;
Now we need to call the function that will bring life to our auto-complete field - setAutoComplete.
&#60;script type=&#8221;text/javascript&#8221;&#62;
$(function(){
Â Â Â  setAutoComplete(&#8221;searchField&#8221;, &#8220;results&#8221;, &#8220;autocomplete.php?part=&#8221;);
});
&#60;/script&#62;
The call to setAutoComplete is inside a jQuery special code that is only executed [...]]]></description>
			<content:encoded><![CDATA[<p>Here we are going to discuss about implement a auto-complete feature using jQuery</p>
<p>&lt;script type=&#8221;text/javascript&#8221; src=&#8221;jquery.js&#8221; mce_src=&#8221;jquery.js&#8221;&gt;&lt;/script&gt;</p>
<p>&lt;script type=&#8221;text/javascript&#8221; src=&#8221;dimensions.js&#8221; mce_src=&#8221;dimensions.js&#8221;&gt;&lt;/script&gt;</p>
<p>&lt;script type=&#8221;text/javascript&#8221; src=&#8221;autocomplete.js&#8221; mce_src=&#8221;autocomplete.js&#8221;&gt;&lt;/script&gt;</p>
<p>Now we need to call the function that will bring life to our auto-complete field - setAutoComplete.</p>
<p>&lt;script type=&#8221;text/javascript&#8221;&gt;</p>
<p>$(function(){</p>
<p>Â Â Â  setAutoComplete(&#8221;searchField&#8221;, &#8220;results&#8221;, &#8220;autocomplete.php?part=&#8221;);</p>
<p>});</p>
<p>&lt;/script&gt;</p>
<p>The call to setAutoComplete is inside a jQuery special code that is only executed when the DOM is ready, or in other words, when all the code is already loaded. The setAutoComplete function takes 3 parameters:</p>
<p>the id of the input field<br />
the id of the div that will hold the returned data<br />
the URL of the remote script that will process the request<br />
Be aware that the URL should reflect your remote script and that it will be combined with the text typed in the input field.</p>
<p>Now we include our stylesheet to define the look of the elements. We need to define the styles of the div that will contain the results, they include two classes for the selected and unselected items. Take a look at the CSS file linked at the end of this post. There is also a style for the input field.</p>
<p>&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;autocomplete.css&#8221; mce_href=&#8221;autocomplete.css&#8221; type=&#8221;text/css&#8221;&gt;</p>
<p>To finish the client side part now we need to define the code of the input field as follows:</p>
<p>&lt;label for=&#8221;searchField&#8221;&gt;Colors: &lt;/label&gt;</p>
<p>&lt;input type=&#8221;text&#8221; id=&#8221;searchField&#8221; name=&#8221;searchField&#8221;&gt;</p>
<p>We are almost there! Now that the client side is finished it&#8217;s time for the server script. Here is an example of a script that try to match colors. I&#8217;m using PHP but you can use whatever language you prefer for the job, of course. You just need to return the results as an array encoded as JSON.</p>
<p>// define the colors array</p>
<p>$colors = array(&#8217;black&#8217;, &#8216;blue&#8217;, &#8216;brown&#8217;, &#8216;green&#8217;, &#8216;grey&#8217;,</p>
<p>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  &#8216;gold&#8217;, &#8216;navy&#8217; , &#8216;orange&#8217;, &#8216;pink&#8217;, &#8217;silver&#8217;,</p>
<p>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  &#8216;violet&#8217;, &#8216;yellow&#8217;, &#8216;red&#8217;);</p>
<p>Â </p>
<p>// check the parameter</p>
<p>if(isset($_GET[&#8217;part&#8217;]) and $_GET[&#8217;part&#8217;] != &#8216;&#8217;)</p>
<p>{</p>
<p>Â Â Â Â Â Â Â  // initialize the results array</p>
<p>Â Â Â Â Â Â Â  $results = array();</p>
<p>Â </p>
<p>Â Â Â Â Â Â Â  // search colors</p>
<p>Â Â Â Â Â Â Â  foreach($colors as $color)</p>
<p>Â Â Â Â Â Â Â  {</p>
<p>Â Â Â Â Â Â Â Â Â Â Â Â Â Â  // if it starts with &#8216;part&#8217; add to results</p>
<p>Â Â Â Â Â Â Â Â Â Â Â Â Â Â  if( strpos($color, $_GET[&#8217;part&#8217;]) === 0 ){</p>
<p>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  $results[] = $color;</p>
<p>Â Â Â Â Â Â Â Â Â Â Â Â Â Â  }</p>
<p>Â Â Â Â Â Â Â  }</p>
<p>Â </p>
<p>Â Â Â Â Â Â Â  // return the array as json</p>
<p>Â Â Â Â Â Â Â  echo json_encode($results);</p>
<p>Â </p>
<p>Â Â Â Â Â Â Â  // or return using Zend_Json class</p>
<p>Â Â Â Â Â Â Â  // require_once(&#8217;Zend/Json/Encoder.php&#8217;);</p>
<p>Â Â Â Â Â Â Â  // echo Zend_Json_Encoder::encode($results);</p>
<p>}</p>
<p>Done! As said before, we return the data as an array encoded as JSON. If you are running PHP &gt;= 5.2.0 or the json extension you simply use json_encode for the job. Another option is to use Zend_Json_Encoder from the Zend Framework!<br />
Â </p>
<p>Â 
</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.chrisranjana.com/javascripts/auto-complete-feature-using-jquery.html/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
