PHP field validation script

I need to submit a form field that allows for any 5 digit number (any order). The HTML input field code would look like this:

Reference Number:   <input type=“refnum” name=“refnum” class=“refnum”>

There would need to be some PHP code that receives this data and validates it, then sends the user to a particular page if the field validates; otherwise, display a message. I think the basic PHP string statement would look something like this:

^[[:digit]]{5}$

I’m not a PHP programmer (I work with Actionscript), so I would appreciate some help with the PHP script.