วันอาทิตย์ที่ 2 กุมภาพันธ์ พ.ศ. 2557

PHP ส่งค่าตัวแหร ไปหน้าอื่น


สมมติว่าเราต้องการส่งค่าจาก file1.php ไปยัง file2.php
ใน file1.php เราก็ต้องใส่ method get ลงไปก่อน
<td>
        <form action="search.php" method="get" target="_blank";>
            <input type="text" name="search" style="border:0">
            <td>
            <input type="submit" value="Search" style="border:0;">
            </td>
        </form>
</td>

จากนั้นใน file2.php
<?php
$var_value = $_GET['search'];
echo 'Hello ' . $var_value . '!';
?>
เท่านี้ก็เรียบร้อยโรงเรียนจีน

ที่มา
http://stackoverflow.com/questions/871858/php-pass-variable-to-next-page

ไม่มีความคิดเห็น:

แสดงความคิดเห็น