【发布时间】:2020-08-28 07:22:58
【问题描述】:
所以基本上我有网站托管我的网站,以及用于构建网站的 wordpress。在网站的主页上,我有一个 php 代码 sn-p 插件,可以让我放置 php 代码。 php 代码有一个典型的 html 表单,其输入类型为 select,可让您从下拉菜单中选择产品。选择并点击提交按钮后,forms动作是网站根目录下的filterReceive.php文件。
一旦表单提交给 filterReceive.php,我的代码会接收用户从下拉列表中选择的产品,并根据产品,我希望它将用户重定向到该产品页面。
以下是我将用户重定向到页面的代码:
<?php
if (isset($_REQUEST["submit-button"])){
$product = $_GET['product'];
if($product == "fridge"){
echo "entered function";//this text shows up when the filterReceive.php loads up, so the header function below should also execute
header ("Location: https://www.ebay.com/");//this header function dosent execute no matter what, even if i use relative file in the directory
exit();
}
}
?>
任何帮助将不胜感激,我只是尝试构建简单的 php 代码,在客户从下拉列表中选择产品并单击提交后将其重定向到正确的产品页面。如果在其他地方有任何类似的 wordpress 想法或插件,链接将非常有帮助。非常感谢大家!
【问题讨论】:
-
删除
echo部分,它会重定向——看来你已经关闭了错误报告!否则你会看到警告
标签: php wordpress redirect header