Monthly Archives: November 2011

How to create a simple captcha validation in

We often see captcha validation in number of sites outthere. Earlier, when I started surfing in web, I wondered how they are created. But now I have answer for that.I am presenting you before, a simple method to implement a captcha validation in your websites (PHP folks, cheer up. I am working on a similiar thing in php too.). In this method I am using System.Drawing namespace in C#. First I am going to create a generic handler which will render the captcha image.Look at the code below

And now we are going to implement the validation. Create an aspx page, add add an img tag and for the src attribute,give the path to the handler. See below.

And now it’s time for testing the validation. Code behind will look like this.

And we are done! The validation form will look like this. Download sample project Try this and let me know the feedback.Cheers

How to add httpcompression in php using .htaccess

Compression is a simple, effective way to save bandwidth and speed up your site.HTTP compression is a capability that can be built into web servers and web clients to make better use of available bandwidth, and provide faster transmission speeds between both.[1] HTTP data is compressed before it is sent from the server: compliant browsers will announce what methods are supported to the server before downloading the correct format; browsers that do not support compliant compression method will download uncompressed data. The most common compression schemas include gzip and deflate, however a full list of available schemas is maintained by IANA. Additionally, it is known that third parties develop new methods and include them in their products (e.g. the Google SDCH schema implemented in Google Chrome browser and used on certain Google servers). To enable compression in php using deflate, just add the following lines in your htaccess file.

Deflate is quick and works, so I use it; use mod_gzip if that floats your boat. In either case, Apache checks if the browser sent the “Accept-encoding” header and returns the compressed or regular version of the file. However, some older browsers may have trouble (more below) and there are special directives you can add to correct this.