Skip to content
Advertisement

Passing variables to another page with url – PHP

I want to execute some PHP code by clicking on a link and Passing variables to another page with url Pleas help me.

Such WordPress Site: https://www.armandl.com/?p=5123

Advertisement

Answer

You set $_SESSION['status'] to 0 and then set it to 1, so it will always be 1. Additionally, the link you click has nothing to do with the session vars.

Page 1:

Normally to get just one variable from one page to another via hyperlink you would add it to the URL as a query parameter and access it using $_GET:

JavaScript

Page 2:

You also need to check if $_GET['status'] is set:

JavaScript

Now, if you want it to be accessible on other pages without passing in the URL, then set it as a session var:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement