我完全陷入困境,并希望得到一些帮助。我尝试复制过去类似问题的代码(位于此处URL Redirect from Zipcode Form Entry)并且它不起作用。
我想要一个简单的单行表单,用户可以输入他们的邮政编码,它会自动将它们重定向到合作伙伴网站。 IE浏览器。用户输入80013并将其转发至www.domain1.com。用户输入80303并将其转发至www.domain3.com
表单HTML:
<form method='GET' action='http://harvestmeat.com/regional-ads-by-zip-codes.php'>
<div class="zipcode">
<label for="zip">Zip Code: </label>
<input name="zip" type="text" maxlength="5" id="zip" />
</div>
<div class="button">
<input type='submit' name="did_submit" value="Get Started!">
</div>
</form>
区域的广告逐拉链codes.php:
<?php
$zip = $_GET['zip'];
$loc1 = array (80013,80015,80007);
$loc2 = array (80601,80602,89509);
$loc3 = array (80303,80305);
if(in_array($zip, $loc1)) {
header('Location: http://www.domain1.com');
}
if(in_array($zip, $loc2)) {
header('Location: http://www.domain2.com');
}
if(in_array($zip, $loc3)) {
header('Location: http://www.domain3.com');
}
else {
header('Location: http://www.allelse.com');
}
答案 0 :(得分:0)
<form method='GET' action='http://harvestmeat.com/regional-ads-by-zip-codes.php'>
<div class="zipcode">
<label for="zip">Zip Code: </label>
<input name="zip" type="text" maxlength="5" id="zip" />
</div>
<div class="button">
<input type='submit' name="did_submit" value="Get Started!">
</div>
</form>
<?php
if (isset($_GET['did_submit'])) {
$zip = $_GET['zip'];
$loc1 = array (80013,80015,80007);
$loc2 = array (80601,80602,89509);
$loc3 = array (80303,80305);
if(in_array($zip, $loc1)) {
header('Location: http://www.domain1.com');
}else if(in_array($zip, $loc2)) {
header('Location: http://www.domain2.com');
}else if(in_array($zip, $loc3)) {
header('Location: http://www.domain3.com');
}else {
header('Location: http://www.allelse.com');
}
}
?>