所以基本上,如果他们输入85700到85775之间的邮政编码,我希望它发布到:http://medicarechoicesofarizona.com/
如果输入了其他内容,我希望它像下面一样发布到http://www.ehealthmedicare.com。我想JavaScript也可以,但PHP会很棒,因为这是一个Wordpress小部件。谢谢大家!
<form action="http://www.ehealthmedicare.com/find-coverage?allid=Med35993" method="post" target="blank" _lpchecked="1">
<p style="font-size:16px; text-align:center">
Zip Code: <input type="text" name="zip" style="width:60px; height: 25px;">
</p>
<p style="text-align:center">
<input type="image" src="/wp-content/plugins/medicare-quote-widget/ehealth-medicare-go.png" title="Find Medicare Insurance Options" alt="Find Medicare Insurance Options" class="go-btn">
</p>
</form>
答案 0 :(得分:1)
您可以使用curl扩展名。检查功能,例如:
function post($url, $data) {
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
}
这样称呼:
if($zip > 85699 && $zip < 85776) {
$url = 'http://url1';
} else {
$url = 'http://url2';
}
post($url, 'foo=bar&hello=world');
答案 1 :(得分:0)
实际上,这可以用纯PHP来完成:
<form action="forwarder.php" method="post" target="blank" _lpchecked="1">
<p style="font-size:16px; text-align:center">
Zip Code: <input type="text" name="zip" style="width:60px; height: 25px;">
</p>
<p style="text-align:center">
<input type="image" src="/wp-content/plugins/medicare-quote-widget/ehealth-medicare-go.png" title="Find Medicare Insurance Options" alt="Find Medicare Insurance Options" class="go-btn">
</p>
</form>
然后将其添加到forwarder.php
:
<?php
if($_POST)
{
$zip = (int)$_POST['zip'];
if($zip >= 85700 && $zip <= 85775)
{
header('Location: http://medicarechoicesofarizona.com/');
}
else
{
header('Location: http://www.ehealthmedicare.com/find-coverage?allid=Med35993');
}
}
?>