У меня есть форма на моем сайте Wordpress, которая принимает почтовый индекс, когда она будет отправлена на статическую страницу для этой области обслуживания.У меня проблемы с отправкой данных из моей формы в функцию php.Я попытался поиграть с атрибутами короткого кода и установить действие формы zip-finder.php.Буду признателен за любую помощь ..
Форма:
/*<div class="zip"><form action="[zip_finder]" method='post'>Check pricing and availability in your city or town: <input name='zip' size="12" type="text" placeholder="Enter Zip Code" /> <button id="zip" type="submit">Get Started</button></form></div></p>
*/
I have added the line include('zip-finder.php'); to my theme functions.php file.
PHP-файл, который обрабатывает данные формы:
//<?php
function zipfinder_function() {
$zip=$_POST['zip'];
//commented out some things I tried to get it to work
/*$a = shortcode_atts( array(
'zip' => 'something',
'bar' => 'something else',
), $atts);*/
//switch ($atts['zip'])
switch ('zip')
{
case "02052":
header("Location: https://somewebsiteurl.com/");
break;
case "02056":
header("Location: https://somewebsiteurl.com/");
break;
case "02090":
header("Location: https://somewebsiteurl.com/");
break;
default;
//header("Location: https://websiteurl.com/");
break;
}
}
add_shortcode('zip_finder', 'zipfinder_function');
//?>
I've tried using short code attributes: [zip_finder zip="zip"]