The first thing you need to do is not trust any data from external sources, including form data. (It's very easy to send fake form data, plus you never know what stupid things even non-malicious users may type into a form.) You should check each of the $_POST fields that you are going to use in your script to ensure that the values are valid in terms of content and length, rejecting the input with an error if not.
Secondly, you need to protect against SQL injection attacks with any such values used in your database queries. This is rather easily done by using the [man]mysql_real_escape_string/man function. (The linked page includes a number of useful examples.) As to why this is an issue, see this page.
PS: For an example and some comic relief, see http://xkcd.com/327/. 🙂
PPS: Also, please learn to use the
[url=http://phpbuilder.com/board/misc.php?do=bbcode]BBCode tags[/url] around your code samples to make them much easier for us to read.