发送提交表格后是否打开特定页面

I would to open a popup message after my contact form is sent or receive a error popup. If press close on alert I would to open the index.html page; if there is an error I would to close only the popup so you can't loose the text of the message.

With the actual code I receive the alert message but after close the popup the page load the .php page in the url (blank) but I receive the message in my mail... Thanks to everyone who can help me with the code ;)

Pastie Bin php code

You can use Window.location

On Success

echo "<script type='text/javascript'> alert('Message Sent!'); window.location = 'index.html'; </script>";

On Error

echo "<script type='text/javascript'> alert('ERROR!'); </script>";