我正在尝试创建一个简单的表单,如果用户没有输入邮政编码,则会在同一页面上给他们一个错误。如果他们输入邮政编码,我希望表格转到另一页。有人可以让我知道我做错了什么吗?
<?php
$errors = "";
if(isset($_GET['submit'])){
if(0 === preg_match("/\S+/", $_GET['zip']))
$errors['zip'] = '<li type="square" >To proceed please enter a valid ZIP Code.</li>';
} else {
die(header("Location: success.php"));
}
?>
<?php
if ($errors != "") {
echo $errors['zip'];
}
?>
<form name="zipcodeform" id="zipcodeform" action="" method="GET">
<br />
<h3>Try your self :</h3><br />
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td align="left" valign="top">Zip Code : </td>
<td align="left" valign="top"><input type="text" name="zip" id="zip" value="<?php echo $_GET['zip']; ?>" /></td>
</tr>
<tr>
<td> </td>
<td align="left" valign="top"><input type="submit" name="submit" id="submit" value="Get Quotes >> " /></td>
</tr>
</form>