How to get my data back from one button to another php page

I have a button on a php page with some data on the same page. My button is redirected to another php page and I want to return this data.

I tried to do

if(isset($_POST['button'])){
    echo($data);
}

      

Isset is true (I am doing a test with a string) but I cannot get my data back from this other php page.

My form code of my button:

   <form action = "/lienPaybox.php" method = "post">
      <input type = "submit" name = "button" value = 'Submit'> 
   </form>

      

+3


source to share


1 answer


If you want to transfer data from one page to another Session

is your best choice

All you have to do is initiate a session.

page1.php

β†’ This page contains your data. Below code in your page1.php

<?php
session_start();

$_SESSION['username'] ='Mr.x';
$_SESSION['usertype'] = 'level1';

?>

      



page2.php

-> The page from where you want to get the data in page1.php.Here is the code,

<?php
session_start();
print_r($_SESSION); //You will notice the datas from previous page is being displayed here

?>

      

Of course, there are guidelines that must be followed during processing Sessions

. Once you get Sessions

it you can follow this link Securing Sessions in PHP

+1


source







All Articles