Let's all be examples.
I am redirecting from A.php to B.php with a parameter, let's say it ID=1.
Therefore,

..../B.php?ID=1

And I wanna hold the value of the ID.
Whenever I press a button on B.php, the value ID=1 gone.

Any idea of how can I hold that value ?
Thanks for in advance.

Whenever I press a button on B.php, the value ID=1 gone.

Can you clarify this? Right now it seems the issue is not related to A.php but just to what happens inside B.php.

Yes.
When page load of B.php, I store the value of the URL.

$id = $_GET['cust_no'];

Then whenever I pressed a button on B.php, the value $id become null.

I would like to keep the value of $id after B.php is submit.

I already try using Session to retrieve the value.
But the value of session still null.

A.php

<?php
    function runProrgam() {
        session_start();
        $_SESSION["custno"] = $_GET["cno"];
        ECHO ("<script type='text/javascript'>");
        ECHO ("document.location.href = 'B.php'");
        ECHO ("</script>");
    }

    runProgram();
?>

B.php

    <?php
        function runProrgam() {
             session_start();
             $custno = $_SESSION["custno"];

             ECHO ("This is Session Value " .$custno);
        }
        runProgram();
     ?>

Please also note that my session_start() very top of every pages before HTML and php code

<?php session_start(); ?>
HTML
ANOTHER PHP CODE BEHIND

Hmm, the session in this case it is not, probably, the best approach: what happens if, in the current session, you open multiple tabs of A.php with different IDs?

A.php?id=123
A.php?id=124
A.php?id=125
...

It would screw up, because the session value would be rewritten by the latest loaded tab. Append the query string to B.php, so if you are using a form you can do:

<form method="get" action="B.php?id=123">

Or hide it in the input fields:

<input type="hidden" name="id" value="123">

If you want more appropriated help, share an example of what you are trying to do.

commented: Good shout about multiple tabs +1 - a common gotcha! +0

Thanks for your help.
Now I am enable to execute my program correctly with applied hidden field.
So when 2nd page load, I'll store the URL value into hidden value.

<input type="hidden" name="cno" value="<?php ECHO ($_GET["custno"]); ?>" />

Then whenever a button pressed on 2nd page, I am able to retrieve the value of it.

ECHO ($_GET["cno"]);

Thanks for your help buddy.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.