Different ways of passing variables with data between pages
We can pass the data between pages by following ways:
Passing variable values between pages using session
This is one of the secured ways the variables are passed between pages. The best example of such a system is when we see our user-id inside a member area after we logged in. In a member login system the user details are verified and once found correct, a new session is created and with user id of the member and this value is stored at server end. Every time a new page is opened by the browser, the server checks the associated session value and display the user id. This system is more secure and the member doesn’t get any chance to change the values.
Passing variables between pages using cookies
Cookies are stored at the user or the client end and values can be passed between pages using PHP. But here the client browser can reject accepting cookies by changing the security settings of the browser. So this system can fail to pass values between pages if user or client end settings are changed. But cookies are quit useful in handling user entered values and passing them between pages.
Passing variables between pages using URL
We can pass variable values between pages through the URL ( in address bar of the browser). Here values are visible to the user and others as they appear in the address bar and also in the browser history. This is not a secure way to transfer sensitive data like password, etc.
Forms are used mainly to collect data and then transfer them to a processing page. Here the processing page uses one of the above methods to pass values to different pages as per the requirements. Forms can be used to pass values to different sites. Forms can submit the data to a processing script running at a different URL in different server.