The reason I said it was untested was because in the process of testing it I accidentally got it stuck in a loop, and deleting the script wouldn't even stop it. lol
My webhost had to restart the server, crashing everybody else's sites too. I felt terrible, and I recieved about 12000 emails in the time it took me to get it resolved.

Anyways, now it is corrected, tested and the script above works perfectly.

Enjoy.
Herk