在WordPress中,表单提交后我尝试重定向到另一个页面,但我不能使用以下内容:
if(isset($_POST['name']))
{
$q=mysql_query("INSERT INTO `contactsus` (name, email, location, mobile, subject, comment, created) VALUES('$name', '$email', '$location', '$mobile', '$subjct', '$comment', '".time()."') ");
if($q)
{
echo '{"responce":"1","message":"Thanks for the registration","url":"'.$_SESSION['SITE_URL'].student.'"}';
}
else
{
echo '{"responce":"0","message":"Your registration request has been failed due to system error"}';
}
}
此代码的结果是:
{
"responce":"1",
"message":"Thanks for the registration",
"url":"http://localhost/manishatutors/student"
}
答案 0 :(得分:0)
为此,您可以使用WordPress的wp_safe-redirect功能,使用wp_redirect()
执行安全(本地)重定向。
答案 1 :(得分:0)
对于wordpress中的重定向,您可以使用
$url=$_SESSION['SITE_URL'].$page;
wp_redirect($url);