Programistyczny
Programistyczny

Reputation: 55

How I can create multiple request get/post page url

How I can create multiple get/post request in 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 i can add more request? now i have http://www.example.com/?goto=profile

i trying 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');

}

Doesn't work page when I add to profile?id="$_GET['id']"')

Upvotes: 4

Views: 90

Answers (2)

Lalit srikar
Lalit srikar

Reputation: 82

$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 those values are not available then you may get

"Notice: Undefined index: " error.

Upvotes: 2

Ali Rasheed
Ali Rasheed

Reputation: 2817

I believe this could be done like this

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

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


require_once('profile.php');

}

another thing I understood this could be done like this

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

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

       header("Location: profile.php");

    }
}

Upvotes: 1

Related Questions