PHP从一个页面变量以在其他页面上自动运行SQL查询

I am currently trying to pass a variable from one page to another then load the query on that page with the passed variable.

My code is as follows:

Awaiting Variable

if(isset($_POST['viewrecord'])){
    $sup_code = $_POST['vhidden'];
}

SQL Query

$sql = "SELECT     sup_code, firstname, lastname, email, telephone
FROM         dbo.table
WHERE sup_code = ('$sup_code')";

Thanks guys, I added the following to the variable on page 2 and this seemed to solve the issue.

$sup_code = preg_replace('/\s+/', '', $_POST['vhidden']);

Try this,

session_start();
if(isset($_POST['viewrecord'])){
    $sup_code = $_POST['vhidden'];
}
$_SESSION["sup_code"] = $sup_code;

SQL Query

$sql = "SELECT     sup_code, firstname, lastname, email, telephone
FROM         dbo.table
WHERE sup_code = '".$_SESSION["sup_code"]."'";