How can I create a request / page url

How can I create multiple receive / send requests in a page url?

Like this:

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

I already tried with this:

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

How can I add more queries? I now have http://www.example.com/?goto=profile

I am trying to do this 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');

}

The page does not work when I add to the profile? id = "$ _ GET ['id']" ')

+4
source share
2 answers
$goto = isset($_GET['goto']) ? $_GET['goto']:null;
$id = isset($_GET['id']) ? $_GET['id']:0;

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

you need to assign these values ​​to variables, if you directly write $ _GET ['id'] in "if condition" and these values ​​are not available, you can get

"Note: Undefined index:" error.

+2
source

I believe this can be done like this:

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

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


require_once('profile.php');

}

another thing, I realized that this can be done like this:

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

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

       header("Location: profile.php");

    }
}
+1
source

Source: https://habr.com/ru/post/1664267/


All Articles