簡體   English   中英

我如何創建多個請求獲取/發布頁面網址

[英]How I can create multiple request get/post page url

如何在頁面URL中創建多個獲取/發布請求?

像這樣:

http://www.example.com/?goto=profile&id=11326

我已經嘗試過了:

$doVariableprofile = isset($_GET['goto']) ? $_GET['goto'] : null;
if($doVariableprofile == 'profile') {
if(empty($_SESSION['logged'])) require_once('register.php');
}

我如何添加更多請求? 現在我有http://www.example.com/?goto=profile

我嘗試這樣做http://www.example.com/?goto=profile&id=1

        $testt1 = isset($_GET['goto']) ? $_GET['goto']:null;
if($_GET['goto'] == 'profile?id=".$_GET['id']"'){


require_once('profile.php');

}

當我添加到個人資料時,頁面不起作用?id =“ $ _ GET ['id']”')

$goto = isset($_GET['goto']) ? $_GET['goto']:null;
$id = isset($_GET['id']) ? $_GET['id']:0;

if($goto == 'profile' && $id != 0){
        require_once('profile.php');
}

您需要將這些值分配給變量,如果您直接在'if condition'中寫入$ _GET ['id']而這些值不可用,那么您可能會得到

“注意:未定義索引:”錯誤。

我相信可以這樣做

$url = "profile?id=".$_GET['id'];

if($_GET['goto'] == $url){


require_once('profile.php');

}

我知道這可以做的另一件事

if(isset($_GET['goto']) && $_GET['goto']=="profile"){

   if(isset($_GET['id'] || $_GET['id']==''){

       header("Location: profile.php");

    }
}

暫無
暫無

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

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