簡體   English   中英

查詢后在wordpress中重定向?

[英]redirect in wordpress after query?

在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"
}

為此,您可以使用WordPress的wp_safe-redirect函數,該函數使用wp_redirect()執行安全(本地)重定向。

可以在wordpress中使用重定向

$url=$_SESSION['SITE_URL'].$page;
             wp_redirect($url);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM