I have some code written in php to validate a postcode field in my form. The code is meant to check that the field is not empty (mandatory) and matches one of 5 usable postcodes, if not it displays an alert. The problem i am having is that when i leave the field empty and hit the submit button the proper alert is show but if i enter a wrong value and hit submit the form just loads to a blank screen, can anyone spot a mistake in my code? :

```
 <?php

 if (isset($_POST['submit'])) {

$post = $_POST["post"];
$words = array('2747','2750','2753','2760','2777');
$msgp = "";

if (!empty($post)) {
foreach ($words as $item)
{
    if (strpos($post, $item) !== false)
        return true;
}
$msgp = '<span class="error"><b>Please enter correct postcode</b></span>';
return false;

} else if(empty($post)) {
$msgp = '<span class="error"><b>Please enter postcode</b></span>';
}

}

?>

<form name="eoiform" method="POST" action="<?php echo $_SERVER["PHP_SELF"];?>" id="eoi">

<b>Post Code</b>
<br>
<input type="text" id="post" name="post" /><?php echo $msgp; ?>

</form>

```