Progress Bar in PHP

Now, first to clarify, this is not a progress bar like in an application, but a progress bar for a web wizard…

Have you ever found yourself making a wizard in PHP, and making the h2 tag “Step 2/5″? Do you want a way to show the user all the steps, while still letting them know what step they are on? If you said yes to both of those questions then I have another, do you think this looks good?

Sorry for sounding like an infomercial but, if you like the look of that, what if I told you that you could have this on your own website for free?

This is a PHP script I have made, it shows your progress through a wizard, and even has support for errors. If you would like to see an example, look at the Progress Bar example page, it has a dummy wizard on it, and if you want to test the error stage, don’t accept the “non existent terms and conditions”. Sorry about the bad spelling on the example, I have not checked it as I was in a rush when I made it…


So, how do I use this in my PHP script?

First you need to include "progress-lib.php"
Then, when you get to the place where you want to add the bar, invoke progress_start(); without any args, then run add_item(str name, bool current, bool error); as many times as needed,

The add_item function takes three args, the name of the step, if that step is the current step, and if that step has an error. So you will need to run this function for each step.

When you are done adding all the steps, you must close the bar by invoking progress_finish(); without any args. You have now successfully made a progress bar.


What may I use this for oh mighty one?

Well, I’m glad you asked! You may use this script for commercial or non-commercial use, as long as the credit in “progress-lib.php” is not edited, modified, or removed.


So, where can I download it?

You can download the main script with an example script included here. If you would like to share what you are using this for, then please, feel free to comment on this post!

Leave a Reply

Your email address will not be published. Required fields are marked *

Please type the characters of this captcha image in the input box

Please type the characters of this captcha image in the input box

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>