1.php

<FORM METHOD='post' ACTION='2.php'>
<input type='text' name='var1'>帳號<BR>
<input type='password' name='var2'>密碼<BR>
<input type=submit value='確認送出'>
</form>

2.php

<?php
$account = $_REQUEST['var1'];
$passwd = $_REQUEST['var2'];

session_start();
session_register("account");
session_register("passwd");

$_SESSION['account'] = $account;
$_SESSION['passwd'] = $passwd;

echo "account:".$account."<BR>\n";
echo "password:".$passwd."<BR>\n";

echo "<a href='3.php'>變數傳送</a>";
?>

3.php

<?php
session_start();
$account = $_SESSION['account'];
$passwd = $_SESSION['passwd'];
echo $account.":帳號<BR>";
echo $passwd.":密碼<BR>";
?>

Last modified: Tuesday, 6 September 2011, 7:54 PM