ต้องถามก่อน ว่าผู้ใช้ จะเดินทางจากหน้า 1 ไปหน้าสองได้อย่างไร
ถ้าผู้ใช้จะไปจากหน้า 1 ไปหน้า 2 ด้วยลิงค์ ก็ให้เอา $customer_id ขอบคุณแปะไปกับลิงค์ที่จะไปหน้า 2 เลยครับ
ประมาณนี้ครับ
หน้าหนึ่ง
<a href="page2.php?cus_id=<?=$customer_id?>">ลิงค์ไปหน้า 2</a>
หน้าสอง
$customer_id = $_GET['cust_id'];
----------------------
แต่ถ้าผู้ใช้จะเดินทางจากหน้า 1 ไปหน้า 2 ด้วย การคลิกปุ่มจาก form ก็ให้เอาค่าตัวแปร $customer_id ที่ได้ ใส่ไว้ใน hidden field ครับ
ประมาณนี้ครับ
หน้าหนึ่ง
<form method="post" action="page2.php">
<input id="cust_id" name="cust_id" type="hidden" value="<?=$customer_id?>" />
....form element ต่างๆที่จะใส่ก็ใส่เข้าไปเลยครับ
<input type="submit">
</form>
หน้าสอง
$cust_id = $_POST['cust_id'];
