Create a function that grabs the last x amount of messages from an IP address where the timestamp is from 10 seconds or less (you will need to modify your $date variable to include seconds) when a message is submitted. If mysql_num_rows is greater or equal to 4-5, then echo they need to wait...
lmao... if you're making a template system, wtf are you doing this horrid stuff?
look at template frameworks, and you'll see exactly why this is inefficient and just bad practice
http://www.smarty.net/
What are you doing to check to see if it is working properly?
If you ping sub.domain.com and it resolves your Minecraft server IP, then it should work just fine. I did this once for my Quake III server (play.clandynasty.com) and it resolved to our server. We didn't have to specify a port...