Benyaman
Benyaman

Reputation: 449

How to loop a php file when there is a $_GET?

I am a little confused on the structure that i need to build this php file.

I have a $_SESSION['Listingname'] = $_GET['Listingname']; at the start of the file, to get a listingname from the last php file. But i also want to have a button that submit some text and refresh the page. Not sure how i should approach it, because if i refresh/reload the page, then it can't perform $_GET['Listingname'] then it gives an error of undefined method.

Some advice would be appreciated. Thanks

Upvotes: 0

Views: 69

Answers (2)

Ashwini Agarwal
Ashwini Agarwal

Reputation: 4858

Try something like this...

if(!empty($_GET['Listingname'])) {
    $_SESSION['Listingname'] = $_GET['Listingname'];
}

Upvotes: 3

Rakesh Sharma
Rakesh Sharma

Reputation: 13738

try check empty

if(!empty($_GET['Listingname'])) {
    $_SESSION['Listingname'] = $_GET['Listingname'];
}

or try to set in hidden field value of $_SESSION['Listingname'] and send it to again with submit if you want reuse it

Upvotes: 1

Related Questions