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

<channel>
	<title>infinetSoftware</title>
	<atom:link href="http://www.infinetsoftware.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.infinetsoftware.com/blog</link>
	<description></description>
	<pubDate>Wed, 27 Aug 2008 02:19:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Spam Proof your Web Forms</title>
		<link>http://www.infinetsoftware.com/blog/25-spam-proof-your-web-forms/</link>
		<comments>http://www.infinetsoftware.com/blog/25-spam-proof-your-web-forms/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 19:00:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Articles]]></category>

		<category><![CDATA[antispam]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.infinetsoftware.com/blog/?p=25</guid>
		<description><![CDATA[Whether they be comment forms or contact forms, spam bots are crawling your website looking for forms to submit their links to. With comment forms this can be annoying to moderate and with contact forms, it can be annoying to receive nonsense emails designed to spam search engines. In most cases, these bots are &#8220;dumb&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Whether they be comment forms or contact forms, spam bots are crawling your website looking for forms to submit their links to. With comment forms this can be annoying to moderate and with contact forms, it can be annoying to receive nonsense emails designed to spam search engines. In most cases, these bots are &#8220;dumb&#8221; and are just submitting any form they find on the internet hoping something sticks. Because of this, there are several traps we can add to hopefully catch most of these bots and automatically filter out their junk.</p>
<p>One easy trap we can add is a fom element hidden by CSS. Humans won&#8217;t be able to see the element, but bots will find it in your form HTML and will submit something to it. Right there you will be able to distinguish a bot from a normal user and ignore the request.</p>
<pre>&lt;input type="text" name="email2" style="visibility: hidden;"&gt;</pre>
<pre>&lt;?php if (!empty($_POST['email2'])) { return false; } ?&gt;</pre>
<p>Another check you can place is based on a &#8220;fingerprint&#8221; I detected from one seemingly popular spam bot. This particular bot would use your own domain in its email addresses. If it doesn&#8217;t make sense for someone within your organization to submit a form (such as a contact form) using your domain, you can ignore those posts.</p>
<pre>&lt;?php if (strpos($_POST['email'], 'YOURDOMAIN.COM') !== false) { return false; } ?&gt;</pre>
<p>Another trap we can use catches bots trying to hack your email forms. These bots will post mail headers to your email forms in an attempt to use your server to send out email spam. The way to catch these spam bots is to ensure that fields that should only be one line, particularly the email and subject fields, are in fact one line. This hack works by adding new lines into mail headers, and your form should be using one line text inputs for those fields. Any multi line data automatically gives away this attack.</p>
<pre>&lt;?php if (strpos($_POST['email'], "\n") !== false) { return false; } ?&gt;</pre>
<p>&#8220;Dumb&#8221; bots will also generally just crawl your pages to find forms, then submit to the form page using their own methods. More specifically, they won&#8217;t be actually submitting the page your form is on, they simply send their own request to make it seem like they did. This is useful to know for the next two traps.</p>
<p>The first trap is to use Javascript to insert elements into your form that the bot&#8217;s won&#8217;t know about. This is essentially the opposite of the first technique where we want bots to know about fields. In this case you can use Javascript to outut a real form field or hidden field that will be submitted when someone submits your form page, but not when a bot doesn&#8217;t use your form. The below code would go somewhere in between your &lt;form&gt;&lt;/form&gt; tags.</p>
<pre>&lt;script language="Javascript"&gt;document.write('&lt;input type="text" name="Email"/&gt;');&lt;/script&gt;</pre>
<p>The bot would never see this but you would expect to find it on your form page.</p>
<p>The next technique that takes advantage of the bots not actually submitting your form page is to set a session or cookie variable on the form page and verifying it in the submit code.</p>
<pre>&lt;?php
$strCode = md5($_SERVER['REMOTE_ADDR'] . date('YmdHms'));
session_start();
$_SESSION['check'] = $strCode;
?&gt;

&lt;input type="hidden" name="code" value="&lt;?php echo $strCode; ?&gt;"/&gt;</pre>
<p>Then on your form submit page you would check to see if the code field matched the session, like so:</p>
<pre>&lt;?php if ($_SESSION['code'] != $_POST['code']) { return false; } ?&gt;</pre>
<p>This method can be expanded upon so that the actual code isn&#8217;t being passed in the form, but pieces of it along with other identifying characteristics like User Agent. Your PHP code would then re-assemble the pieces to see if they matched the session. Another idea would be to set an expiration on the date, so that the form code is only valid for a certain period of time.</p>
<p>The following is an example of a page that employees several of the above techniques.</p>
<pre>&lt;?php
$strCode = md5($_SERVER['REMOTE_ADDR'] . date('YmdHms'));
session_start();
$_SESSION['code'] = $strCode;
?&gt;

&lt;html&gt;

&lt;head&gt;&lt;title&gt;Contact&lt;/title&gt;&lt;/head&gt;

&lt;body&gt;

&lt;form method="post" action="submitcontact.php"&gt;

&lt;input type="hidden" name="code" value="&lt;?php echo $strCode; ?&gt;"/&gt;

Name: &lt;input type="text" name="Name"/&gt;&lt;br/&gt;
Email: &lt;script language="Javascript"&gt;document.write('&lt;input type="text" name="Email"/&gt;');&lt;/script&gt;&lt;br/&gt;

&lt;input type="text" name="Email2" style="visibility: hidden;"/&gt;

Message: &lt;textarea cols="40" rows="3"&gt;&lt;/textarea&gt;

&lt;input type="submit" value="Send"/&gt;

&lt;/form&gt;

&lt;/body&gt;

&lt;/html&gt;</pre>
<p>And now the code that handles and validates your form:</p>
<pre>&lt;?php

Contact();

function Contact() {
 $strName = $_POST['Name'];
 $strEmail = $_POST['Email'];
 $strEmail2 = $_POST['Email2'];
 $strCode = $_POST['code'];
 
 // Catch Hidden Input
 if (!empty($strEmail2)) {
  return false;
 }
 
 // No Javascript Input?
 if (strlen($strEmail) &lt; 1) {
  return false;
 }
 
 // Email Should be One Line
 if (strpos($strEmail, "\n") !== false) {
  return false;
 }

 // Email Shouldn't Be From Our Domain
 if (strpos($strEmail, 'infinetsoftware.com') !== false) {
  return false;
 }

 // Code Doesn't Match?
 if (empty($_SESSION['code']) || $_SESSION['code'] != $strCode) {
  return false;
 }
 
 // Passed All Tests, Carry on here...
}

?&gt;</pre>
<p>Other methods you can employ include Captchas like <a href="http://recaptcha.net/" target="_blank">reCaptcha</a> or tests like the Wordpress plugin <a href="http://www.herod.net/dypm/" target="_blank">Did You Pass Math?</a> These methods are all traps to catch spam bots that crawl the internet and submit any form they find. If someone was determined to spam your particular site, some of these methods would easily be deafeted, but that little effort will deter almost all of the spam you will encounter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.infinetsoftware.com/blog/25-spam-proof-your-web-forms/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Add AJAX to your PHP Login Form</title>
		<link>http://www.infinetsoftware.com/blog/12-add-ajax-to-your-php-login-form/</link>
		<comments>http://www.infinetsoftware.com/blog/12-add-ajax-to-your-php-login-form/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 18:29:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Articles]]></category>

		<category><![CDATA[ajax]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.infinetsoftware.com/blog/?p=12</guid>
		<description><![CDATA[One good place to sprinkle some AJAX functionality is your login forms. Login forms have two outcomes - either the user gets logged in and taken to protected area of your site or they get an error message. Why keep reloading your login page to show the user login errors when you can do it with [...]]]></description>
			<content:encoded><![CDATA[<p>One good place to sprinkle some AJAX functionality is your login forms. Login forms have two outcomes - either the user gets logged in and taken to protected area of your site or they get an error message. Why keep reloading your login page to show the user login errors when you can do it with Ajax?</p>
<p>We&#8217;ll use a simple login form for our example with a hardcoded username and password to keep things short. You&#8217;re on your own for adding the code to connect to your database to check login credentials.</p>
<p>First we&#8217;ll assume a basic, non AJAX PHP login page with the following code:</p>
<pre>&lt;?php
define('Username', 'ADMIN');
define('Password', 'ADMIN');
$strAction = $_GET['Action'];
if (strtoupper($strAction) == 'LOGIN') {
 TryLogin();
}
function TryLogin() {
 global $strUsernameVal, $blnLoginErr;
 $strUsernameVal = $_POST['Username'];
 $strPasswordVal = $_POST['Password'];
 if ($strUsernameVal == Username &amp;&amp; $strPasswordVal == Password) {
  // Success
  header('Location: index.php');
 }
 else {
  // Invalid Login
  $blnLoginErr = true;
  return false;
 }
}
?&gt;
&lt;html&gt;
&lt;body&gt;
&lt;?php if ($blnLoginErr) { ?&gt;
&lt;p&gt;Error: Invalid login details. Please try again.&lt;/p&gt;
&lt;?php } ?&gt;
&lt;form name="Login" method="post" action="login.php?Action=Login"&gt;
Username: &lt;input type="text" name="Username" value="&lt;?php echo htmlspecialchars($strUsernameVal); ?&gt;"/&gt;&lt;br/&gt;
Password: &lt;input type="password" name="Password"/&gt;&lt;br/&gt;
&lt;input type="submit" value="Login"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>This page will submit to itself and check the form login details against the defined username and password. If the credentials don&#8217;t check, it sets a global page error which is displayed when the page is displayed.</p>
<p>Now to add the Ajax part, we will be using the Prototype library and its Ajax classes. <a href="http://www.prototypejs.org/download">Download Prototype </a>and include the script in the &lt;head&gt;&lt;/head&gt; section of your login page. Next add the following Javascript also to the head section of your page:</p>
<pre>&lt;script language="Javascript"&gt;
function TryLogin() {
 var objForm = document.forms['Login'];
 
 if (!objForm) {
  return true;
 }
 
 var strUsernameVal = objForm.elements['Username'].value;
 var strPasswordVal = objForm.elements['Password'].value;
 
 
 if (strUsernameVal.length &lt; 1 || strPasswordVal.length &lt; 1) {
  var strError = 'Please fill in all required fields.';
  alert(strError);
  return false;
 }
 
 var objParams = {
  method:'post',
  parameters: 'Username=' + strUsernameVal + '&amp;Password=' + strPasswordVal
 }
 var objRequest = new Ajax.Request('ajaxlogin.php', objParams);
 return false;
}
&lt;/script&gt;</pre>
<p>This script grabs the login details from your login form and uses the Prototype Ajax class to post them to an Ajax login script appropriately named ajaxlogin.php. We will now link your login form to the Javascript TryLogin() function. Add the following code inside your &lt;form&gt; opening tag:</p>
<pre>onSubmit="return TryLogin();"</pre>
<p>This will direct your form to the Javascript function or fall back on the standard login if the Javascript is not supported.</p>
<p>You will now need to create a new PHP script called ajaxlogin.php with basically the same login function as login.php, only it will output Javascript that will be executed by the Prototype Ajax class. The following code should be the code for ajaxlogin.php.</p>
<pre>&lt;?php
define('Username', 'ADMIN');
define('Password', 'ADMIN');
header('Content-type: text/javascript');
TryLogin();
function TryLogin() {
 global $strUsernameVal, $blnLoginErr;
 $strUsernameVal = $_POST['Username'];
 $strPasswordVal = $_POST['Password'];
 if ($strUsernameVal == Username &amp;&amp; $strPasswordVal == Password) {
  // Success
  echo("location.href='index.php';");
 }
 else {
  // Invalid Login
  echo("alert('Invalid login details. Please try again.');");
 }
}
?&gt;</pre>
<p>If you notice, the two key differences in this script than your original login page is where the ContentType is set to Javascript and the Javascript that is outputted on login success or failure. The Prototype Ajax class will execute this Javascript on your login page. Keep in mind that anything you want to send from this script must be outputted as Javascript.</p>
<p>The new login.php script would look like this:</p>
<pre>&lt;?php
define('Username', 'ADMIN');
define('Password', 'ADMIN');
$strAction = $_GET['Action'];
if (strtoupper($strAction) == 'LOGIN') {
 TryLogin();
}
function TryLogin() {
 global $strUsernameVal, $blnLoginErr;
 $strUsernameVal = $_POST['Username'];
 $strPasswordVal = $_POST['Password'];
 if ($strUsernameVal == Username &amp;&amp; $strPasswordVal == Password) {
  // Success
  header('Location: index.php');
 }
 else {
  // Invalid Login
  $blnLoginErr = true;
  return false;
 }
}
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Login&lt;/title&gt;
&lt;script language="Javascript" src="prototype.js"&gt;&lt;/script&gt;
&lt;script language="Javascript"&gt;
function TryLogin() {
 var objForm = document.forms['Login'];
 
 if (!objForm) {
  return true;
 }
 
 var strUsernameVal = objForm.elements['Username'].value;
 var strPasswordVal = objForm.elements['Password'].value;
 
 
 if (strUsernameVal.length &lt; 1 || strPasswordVal.length &lt; 1) {
  var strError = 'Please fill in all required fields.';
  alert(strError);
  return false;
 }
 
 var objParams = {
  method:'post',
  parameters: 'Username=' + strUsernameVal + '&amp;Password=' + strPasswordVal
 }
 var objRequest = new Ajax.Request('ajaxlogin.php', objParams);
 return false;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php if ($blnLoginErr) { ?&gt;
&lt;p&gt;Error: Invalid login details. Please try again.&lt;/p&gt;
&lt;?php } ?&gt;
&lt;form name="Login" method="post" action="login.php?Action=Login"&gt;
Username: &lt;input type="text" name="Username" value="&lt;?php echo htmlspecialchars($strUsernameVal); ?&gt;"/&gt;&lt;br/&gt;
Password: &lt;input type="password" name="Password"/&gt;&lt;br/&gt;
&lt;input type="submit" value="Login"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>You should now have a working Ajax powered login form. If Javascript is supported, the form will be submitted via Ajax to your ajaxlogin.php script, which will either direct the login user to the protected area of your site or alert them of invalid credentials. If Javascript is not supported, the old, boring login will be the fallback.</p>
<p>From here you will need to add the code to connect to your database for login credentials. You will also want to add the cookies or session code to actually log the user in. The script in its current state simply redirects the user on a successful login or alerts them of an unsuccessful one.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.infinetsoftware.com/blog/12-add-ajax-to-your-php-login-form/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Write Office Documents with PHP</title>
		<link>http://www.infinetsoftware.com/blog/17-write-office-documents-with-php/</link>
		<comments>http://www.infinetsoftware.com/blog/17-write-office-documents-with-php/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 21:06:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Articles]]></category>

		<guid isPermaLink="false">http://www.infinetsoftware.com/blog/?p=17</guid>
		<description><![CDATA[As a followup to the popular article on how to write office documents with ASP, I&#8217;ll cover the specific code you&#8217;ll need to write MS Office Documents with PHP.
The method we will be using to output Office compatible documents is simple enough - outputting standard HTML. Office has extensive HTML support and will gladly read [...]]]></description>
			<content:encoded><![CDATA[<p>As a followup to the popular article on <a href="http://www.infinetsoftware.com/blog/15-write-office-docs-with-asp/">how to write office documents with ASP</a>, I&#8217;ll cover the specific code you&#8217;ll need to write MS Office Documents with PHP.</p>
<p>The method we will be using to output Office compatible documents is simple enough - outputting standard HTML. Office has extensive HTML support and will gladly read the HTML you send to Office programs like Word or Excel. The topic we will cover in the article is how to get Word or Excel to open your documents.</p>
<p>The first and easiest method to outputting Word or Excel documents would be to simply save your output structured as text/HTML to a file as you normally would, giving it a Word extension of .DOC or an Excel extension of .XLS. Then you can link to this file and when the user downloads or opens it, it will open in Word or Excel on their computer if they have the program installed.</p>
<pre>&lt;?php
$objFile = fopen('FILENAME.DOC', 'w');
fwrite($objFile, $FILECONTENTS);
fclose($objFile);
?&gt;</pre>
<p>The second method will take advantage of HTTP headers to tell the browser your scipt will be outputting an Excel or Word document. The browser will then either display or download the content you output.</p>
<p>To tell the browser you will be outputting a Word document, use the following line of code:</p>
<pre>header('Content-Type: application/msword');</pre>
<p>To tell the browser you will be outputting an Excel document, use the following line of code:</p>
<pre>header('Content-Type: application/vnd.ms-excel');</pre>
<p>It&#8217;s important to note that headers must be sent prior to any other content, so it&#8217;s recommended to place this code at the beginning of your script. Another useful header your script can send will force the browser to download and not display the document in browser. The following line of code will do that and even prefill the filename.</p>
<pre>header('Content-Disposition: attachment;filename=FILENAME.DOC');</pre>
<p>And there you have it. You can now output an HTML formatted document as you normally would and Microsoft Word or Excel will parse and display it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.infinetsoftware.com/blog/17-write-office-documents-with-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Write Office Documents with ASP</title>
		<link>http://www.infinetsoftware.com/blog/15-write-office-docs-with-asp/</link>
		<comments>http://www.infinetsoftware.com/blog/15-write-office-docs-with-asp/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 20:46:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Archive]]></category>

		<guid isPermaLink="false">http://www.infinetsoftware.com/blog/?p=15</guid>
		<description><![CDATA[
ASP has the ability to dynamically output virtually any type of file,
provided that the correct file format is being used. The easiest type to write
would obviously be text, which is what we are already doing when we output
webpages. The other type, binary, is harder to do since ASP doesn&#8217;t natively
support binary variables. Today we will [...]]]></description>
			<content:encoded><![CDATA[<p>
ASP has the ability to dynamically output virtually any type of file,<br />
provided that the correct file format is being used. The easiest type to write<br />
would obviously be text, which is what we are already doing when we output<br />
webpages. The other type, binary, is harder to do since ASP doesn&#8217;t natively<br />
support binary variables. Today we will be using standard text output and the<br />
appropriate MIME file type to turn out a dynamic Microsoft Word document and a<br />
Microsoft Excel document.
</p>
<p><b>ContentType</b></p>
<p>
The first thing we need to do is set the appropriate file type so that the<br />
browser knows what to do with the file. We do this using the ContentType setting<br />
of the Response object. For Word, the content type is <code>application/msword</code>. For<br />
Excel, its <code>application/vnd.ms-excel</code>. So we would use the either of the lines<br />
of code below for Word or Excel documents, respectively. This line must come before ANY<br />
data is output.
</p>
<table width="600" cellspacing="0" cellpadding="0" border="0">
<tr bgcolor="#E7E7E7">
<td><code>Response.ContentType = "application/msword"</code></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr bgcolor="#E7E7E7">
<td><code>Response.ContentType = "application/vnd.ms-excel"</code></td>
</tr>
</table>
<p>
If the user is using Internet Explorer, the file will most likely be sent to<br />
an Office plugin that will show it within the browser window. For different<br />
reasons, this can sometimes be annoying for both the user and the programmer. If<br />
you do not want your file to be displayed in the user&#8217;s browser window, and<br />
instead want to force the save dialog box to pop up, use the line below right<br />
before/after setting the ContentType.
</p>
<table width="600" cellspacing="0" cellpadding="0" border="0">
<tr bgcolor="#E7E7E7">
<td><code>Response.AddHeader &quot;Content-Disposition&quot;, &quot;attachment;filename=NAME.doc&quot;</code></td>
</tr>
</table>
<p><b>Writing the File</b></p>
<p>
Since Word and Excel will take text input, we will be outputting our data in the<br />
same way we do with HTML. Actually, the format we will be using is HTML! Even<br />
color formatting, CSS, and meta tags are supported.</p>
<p>
For Word, you can just write HTML as you normally would, except you are gearing<br />
it towards Word viewing. HTML tables, CSS, and meta tags are all supported. You<br />
can use the meta tags to set the document properties that Word has, such as Title<br />
and Author. Being in Word, you probably would want to stay away from images<br />
unless you know the user will always be connected to the internet to actually see them.
</p>
<table width="600" cellspacing="0" cellpadding="0" border="0">
<tr>
<td><b>Sample Word Document</b></td>
</tr>
<tr bgcolor="#E7E7E7">
<td><code>&lt;%<br />
    Response.ContentType = &quot;application/msword&quot;<br />
    Response.AddHeader &quot;Content-Disposition&quot;, &quot;attachment;filename=receipt.doc&quot;</p>
<p>    Dim strName, strAddress</p>
<p>    strName = Request.Form(&quot;Name&quot;)<br />
    strAddress = Request.Form(&quot;Address&quot;)</p>
<p>    %&gt;<br />
    &lt;html&gt;</p>
<p>    &lt;head&gt;<br />
    &lt;title&gt;Word Test&lt;/title&gt;<br />
    &lt;meta name=&quot;Author&quot; content=&quot;Acme Toys&quot;&gt;</p>
<p>    &lt;style type=&quot;text/css&quot;&gt;</p>
<p>    .BigTitle {<br />
    font-family: Verdana, Sans-Serif;<br />
    font-size: 20pt;<br />
    font-weight: bold;<br />
    color: #004080;<br />
    }</p>
<p>    .UserDetails {<br />
    font-family: Courier New, Monospace;<br />
    font-size: 12pt;<br />
    }</p>
<p>    &lt;/style&gt;</p>
<p>    &lt;/head&gt;</p>
<p>    &lt;body&gt;</p>
<p>    &lt;span class=&quot;BigTitle&quot;&gt;Sample Receipt&lt;/span&gt;</p>
<p>    &lt;p&gt;<br />
    Thank you for purchasing, your order will be shipped within 2 business<br />
    days. Below are the shipping details, provided by you.<br />
    &lt;/p&gt;</p>
<p>    &lt;p&gt;<br />
    &lt;table cellspacing=&quot;1&quot; cellpadding=&quot;1&quot; border=&quot;0&quot;&gt;<br />
    &lt;tr&gt;<br />
    &lt;td&gt;&lt;b&gt;Name:&lt;/b&gt;&lt;/td&gt;<br />
    &lt;td&gt;&lt;span class=&quot;UserDetails&quot;&gt;&lt;%=strName%&gt;&lt;/span&gt;&lt;/td&gt;<br />
    &lt;/tr&gt;<br />
    &lt;tr&gt;<br />
    &lt;td&gt;&lt;b&gt;Address:&lt;/b&gt;&lt;/td&gt;<br />
    &lt;td&gt;&lt;span class=&quot;UserDetails&quot;&gt;&lt;%=strAddress%&gt;&lt;/span&gt;&lt;/td&gt;<br />
    &lt;/tr&gt;<br />
    &lt;/table&gt;<br />
    &lt;/p&gt;</p>
<p>    &lt;/body&gt;</p>
<p>    &lt;/html&gt;</code></td>
</tr>
</table>
<p>
The same applies for Excel as does for Word except you are writing an HTML<br />
table to make your sheet. You can even use Excels functions by outputting the<br />
function as the table cell value.</p>
<table width="600" cellspacing="0" cellpadding="0" border="0">
<tr>
<td><b>Sample Excel Document</b></td>
</tr>
<tr bgcolor="#E7E7E7">
<td><code>&lt;%<br />
    Response.AddHeader &quot;Content-Disposition&quot;, &quot;attachment;filename=invoice.xls&quot;<br />
    Response.ContentType = &quot;application/vnd.ms-excel&quot;</p>
<p>    Dim strName, intOrderCount, intPricePer</p>
<p>    strName = Request.Form(&quot;Name&quot;)<br />
    intOrderCount = Request.Form(&quot;Orders&quot;)<br />
    intPricePer = Request.Form(&quot;Price&quot;)</p>
<p>    %&gt;<br />
    &lt;table width=&quot;90%&quot; border=&quot;2&quot; bordercolor=&quot;green&quot;&gt;<br />
    &lt;tr&gt;<br />
    &lt;th width=&quot;70%&quot;&gt;&lt;b&gt;Name&lt;/b&gt;&lt;/th&gt;<br />
    &lt;th width=&quot;15%&quot;&gt;&lt;b&gt;Price&lt;/b&gt;&lt;/th&gt;<br />
    &lt;th width=&quot;15%&quot;&gt;&lt;b&gt;Quantity&lt;/b&gt;&lt;/th&gt;<br />
    &lt;/tr&gt;<br />
    &lt;tr&gt;<br />
    &lt;td width=&quot;70%&quot;&gt;&lt;%=strName%&gt;&lt;/td&gt;<br />
    &lt;td width=&quot;15%&quot;&gt;&lt;%=intPricePer%&gt;&lt;/td&gt;<br />
    &lt;td width=&quot;15%&quot;&gt;&lt;%=intOrderCount%&gt;&lt;/td&gt;<br />
    &lt;/tr&gt;<br />
    &lt;tr&gt;<br />
    &lt;td colspan=&quot;2&quot; align=&quot;right&quot;&gt;&lt;b&gt;Total:&lt;/b&gt;&lt;/td&gt;<br />
    &lt;td align=&quot;left&quot;&gt;=product(b2,c2)&lt;/td&gt;<br />
    &lt;/tr&gt;<br />
    &lt;/table&gt;</code></td>
</tr>
</table>
<p>
As you can see, with the simplicity of writing Word/Excel documents, you can<br />
easily implement them into your site where needed. Other possible uses<br />
include expense sheets retrieved from a database and formatted in<br />
Excel, or printable forms in Word with dynamic user information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.infinetsoftware.com/blog/15-write-office-docs-with-asp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Scriptaculous AutoComplete with PHP</title>
		<link>http://www.infinetsoftware.com/blog/6-scriptaculous-autocomplete-with-php/</link>
		<comments>http://www.infinetsoftware.com/blog/6-scriptaculous-autocomplete-with-php/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 16:49:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Articles]]></category>

		<category><![CDATA[ajax]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.infinetsoftware.com/blog/?p=6</guid>
		<description><![CDATA[Looking to add an auto suggest box on your website that searches your database? This article shows you how to use the Scriptaculous Ajax.AutoCompleter with PHP and MySQL to build a database powered autosuggest box.
First make sure you have the Scriptaculous library downloaded and included in your webpage. After you have downloaded the library and [...]]]></description>
			<content:encoded><![CDATA[<p>Looking to add an auto suggest box on your website that searches your database? This article shows you how to use the Scriptaculous Ajax.AutoCompleter with PHP and MySQL to build a database powered autosuggest box.<br />
First make sure you have the <a href="http://script.aculo.us/">Scriptaculous library</a> downloaded and included in your webpage. After you have downloaded the library and placed it in your website&#8217;s folder, including it is as simple as adding the following script tags between your head tags.</p>
<pre><code class="javascript">&lt;script src=<span class="string">"prototype.js"</span> type=<span class="string">"text/javascript"</span>&gt;&lt;<span class="regexp">/script&gt;
&lt;script src="</span>scriptaculous.js<span class="string">" type="</span>text<span class="regexp">/javascript"&gt;&lt;/</span>script&gt;</code></pre>
<p>Now, on to create the autcompleter in your webpage. Add the following code in your page where the Autocompleter should appear:</p>
<pre>&lt;p&gt;
&lt;form&gt;
&lt;input type="text" name="q" id="Search" size="30"/&gt;
&lt;input type="submit" value="Search"/&gt;
&lt;/form&gt;
&lt;/p&gt;</pre>
<pre>&lt;div id="SuggestBox" style="border: 1px solid #808080; background-color: #FFFFFF;"&gt;&amp;nbsp;&lt;/div&gt;</pre>
<p>The SuggestBox div is where the search results will appear. You don&#8217;t need to worry about CSS positioning, Scriptaculous will automatically display it appropriately below your suggest input.</p>
<p>You will now need to add some Javascript to your page to use the Scriptaculous AutoCompleter and link it to your form and suggest div. Place the following code at the end of your page to enable your autocompleter.</p>
<pre>&lt;script language="Javascript"&gt;
function AutoComp() {
  var myAutoCompleter = new Ajax.Autocompleter('Search', 'SuggestBox', 'autocompleter.php');
}
document.onLoad = AutoComp();
&lt;/script&gt; </pre>
<p>This code creates a new Autocompleter and points it to the input with id &#8220;Search&#8221;, suggest div with id &#8220;SuggestBox&#8221;, and a PHP script named &#8220;autocompleter.php&#8221; located in the same folder on your site as the current page.</p>
<p>Now for the PHP/MySQL part of the article. Create the script named &#8220;autocompleter.php&#8221; as referenced above. Scriptaculous will use POST and the form input name to pass the search terms to your PHP script, so we will need to reference that for our search.</p>
<p>The following is an exampe of the PHP script you would use to search an &#8220;Articles&#8221; table in your database. Simply change the SQL as needed to search a different table.</p>
<pre>&lt;?php

$strSearchVal = $_POST['q'];</pre>
<pre>if (strlen($strSearchVal) &lt; 1) {
 return false;
}</pre>
<pre>// Sanitize User Input for Security
$strSearchVal = mysql_real_escape_string($strSearchVal);</pre>
<pre>// Connect to your database here:
mysql_connect('localhost', 'user', 'pass') or die(mysql_error());
mysql_select_db('dbname');</pre>
<pre>$strSQL = 'SELECT ID, Name FROM Articles WHERE (Name LIKE \'%' . $strSearchVal . '%\')';
$result = mysql_query($strSQL);</pre>
<pre>echo '&lt;ul&gt;';</pre>
<pre>while ($arrThisRow = mysql_fetch_array($result)) {
 echo '&lt;li&gt;' . $arrThisRow['Name'] . '&lt;/li&gt;';
}</pre>
<pre>echo '&lt;/ul&gt;';</pre>
<pre>?&gt;</pre>
<p>And now you should have a working autocompleter powered by PHP and MySQL.</p>
<p>Tips:</p>
<ul>
<li>You can better style the SuggestBox list with CSS.</li>
<li>When using the autocompleter as a search form, you can add links to the list items to take the user to the page when the item is selected, rather than simply populating the search input.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.infinetsoftware.com/blog/6-scriptaculous-autocomplete-with-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Smart Support</title>
		<link>http://www.infinetsoftware.com/blog/3-smart-support/</link>
		<comments>http://www.infinetsoftware.com/blog/3-smart-support/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 15:05:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Smart Support]]></category>

		<guid isPermaLink="false">http://www.infinetsoftware.com/blog/?p=3</guid>
		<description><![CDATA[After many months of development, we have finally launched Smart Support, our full featured PHP based customer support help desk. Checkout Smart Support, browse through the screenshot tour, take the demo for a drive, or order here.
]]></description>
			<content:encoded><![CDATA[<p>After many months of development, we have finally launched Smart Support, our full featured PHP based customer support help desk. Checkout <a href="http://www.infinetsoftware.com/products/support/">Smart Support</a>, browse through the <a href="http://www.infinetsoftware.com/products/support/screenshots.php">screenshot tour</a>, take the <a href="http://www.infinetsoftware.com/products/support/demo.php">demo</a> for a drive, or <a href="http://www.infinetsoftware.com/products/support/order.php">order here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.infinetsoftware.com/blog/3-smart-support/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
