I tried you code on my PC and it works fine except that it shows the thanks message twice. Once before the form, and the other after the form upon successful form submission. I have modified the code a bit, you may try it.
<html>
<head>
</head>
<body>
<?php
if (isset($_POST['submit'])) {
if ( empty($_POST['email'])
||
!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$_POST['email'])) {
$msg = 'please provide a valid email';
} else {
$email = $_POST['email'];
$recipient = "myemail@myemail.com";
$subject = "Contact Form Email Subject";
$message = "your email message";
$mailheader = "From: $email \n";
mail($recipient, $subject, $message, $mailheader) or die("Error!");
$msg = "<font color='green' size='3'>Thank You for your message.</font>";
}
}
?>
<form method="POST">
<p align="center">
Enter your valid email id: <br> <input type="text" name="email"> <br>
<input type="submit" name="submit" value="Subscribe now!">
</form>
<?php
echo $msg;
?>
</body>
</html>