PHP - How do i randomly display pictures - Asked By Olusegun A. on 08-Dec-09 03:17 PM

I want to use pictures as my CAPTCHA on my form page., i have all the pictures i want in my picture folder. is it possible or how do i display a different picture every time my form page is refreshed or visited?

If it is not possible, kindly recommend wayout.


Javascript - F Cali replied to Olusegun A. on 08-Dec-09 03:41 PM

You can use javascript to display random images on your web page.  Here's a link to javascript that does that function:

All you have to do is provide the list of images you would want to display on your page and the javascript will take care of randomizing it.

SQL Server Helper

Image load for CAPTCHA - Venkat K replied to Olusegun A. on 08-Dec-09 09:29 PM

Actually instead of loading random image. While implementing  CAPTCHA we usually display only a single plain image and add the text to that image randomly.

So here we will generate only text randomly:

Here is an excellent demo how can we generate a random string and show on image:

Complete example:

Hope this helps!


randomly display pictures - mv ark replied to Olusegun A. on 09-Dec-09 04:53 AM
Rename image file names with sequential numbers. Use the rand function to generate a random number from a specified range -

Use the random number to form a meaningful file path to show a random image each time.