user1112495
user1112495

Reputation: 13

Get Parameter from URL using PHP

I have a url:

domain.com/?city=newyork&postback=test

I am currently successfully passing the postback parameter using the PHP below. However, I can not figure out how to also pass the city parameter.

<?php session_start(); 

if(isset($_SESSION['postback'])) {
    if($_GET['postback'] == "") {
        header ("Location: qualify-step2.php?postback=".$_SESSION['postback']);
        }
    }

 ?>

Can someone please help me edit the code successfully? Any suggestions are greatly appreciated.

Upvotes: 0

Views: 120

Answers (3)

Deon Okonkwo
Deon Okonkwo

Reputation: 165

You should use the $_GET superglobal to get params from url... In your case $_GET['city'] holds the value newyork and $_GET['postback'] holds the value test.

Upvotes: 2

Rohit Gupta
Rohit Gupta

Reputation: 4185

You mean like this

<?php session_start(); 

if(isset($_SESSION['postback'])) {
    if($_GET['postback'] == "") {
        header ("Location: qualify-step2.php?postback=".$_SESSION['postback']."&city=".$_SESSION['city']);
        }
    }

?>

Upvotes: 0

user4920811
user4920811

Reputation:

For geting parameter from URL, you should use $_GET['param'];.

Note: In here, You should use Get method for sending data.

Upvotes: 0

Related Questions