PHP

PHP

Watermark image

Monday, July 23rd, 2007 in PHP | 9 comments

watermark Do you need to watermark your images? If so, do it the smart way. Put your mark on them by resizing the watermark. If you upload images having different sizes, you’ll love this. Read on.

Over the time I had clients that wanted to put a watermark on their images for copyright purposes. But there was a little problem. The watermark was too small on bigger images and too big on smaller ones. What to do… what to do?! Resize the watermark of course! (more…)

Tags: , ,

Image titles generated with PHP and GD

Saturday, July 21st, 2007 in PHP | 1 comment

image titles generated with php Some time ago, a client came and asked specifically that the headers (h1 stuff) should use his particular font specified in his identity manual. At that time I did now knew about the flash possibility to overwrite text (search for sIFR.js and you’ll see what I mean), so I chose to dynamically generate these titles using and GD. The reason for this solution (instead of changing them using some image editing software) was that there was some dynamic data (a list of newsletters) that needed the same title styling. (more…)

Tags: ,

Simple PHP math captcha image

Friday, June 22nd, 2007 in PHP | 38 comments

math captcha image There are tons of captcha scripts on the web. The problem is that, from the enthusiasm of making them more flexible, a lot of code and pages are added and instead of a simple solution one may end up with several files necessary to display the captcha image. I’m not saying that they are useless, but for most of the time, such complexity is not quite welcomed. I strongly believe that less is more and that things should be kept simple. Having that in mind, I want to share a way to protect your forms using a math captcha image that requires a single file and a font file.

This is a very simple, easy to understand example that shows you how to display a math captcha image that requires the user to do a little thinking. Simple operation like subtraction or addition is displayed on the math captcha and the user needs to input the result. Math captcha result is stored in session and from the page doing the form validation you just need to compare the value from session with the value that the user inputed. (more…)

Tags: ,

Simple PHP-GD captcha image

Thursday, June 21st, 2007 in PHP | 12 comments

If you need to secure a form from being automatically submitted by robots of by someone who wants to damage your server and/or scripts, it’s best that you use a captcha image.
For this one you’ll need compiled with GD and the FreeType Support enabled (in order to use True Type fonts in your images). (more…)

a few things you must never do when quering database

Tuesday, June 19th, 2007 in PHP | no comments

I’m putting this in here because I’ve done it myself and I’ve seen it done by others.
NEVER EVER use mysql_query() in a loop (like while(), for(), foreach() … ). It will slow down your script and drive you nuts. It’s the wrong way of doing anything you have in mind. (more…)