標籤:style class blog c code java
----- 012-form.html -----
<!DOCTYPE html><html><head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>一個PHP網頁</title></head><body><center> <form action="012-session.php"> 使用者名稱:<input type="text" name="username"/><br/> 密 碼:<input type="text" name="password"/><br/> <input type="submit" name="submit" value="登入"/> <input type="reset" name="reset" value="重設"/> </form></center></body></html>
----- 012-session.php -----
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="content-type" content="text/html; charset=utf-8"> 5 <title>一個PHP網頁</title> 6 </head> 7 <body> 8 <?php 9 echo "儲存會話<br/>";10 session_start();11 $_SESSION[‘username‘] = $_GET[‘username‘];12 $_SESSION[‘password‘] = $_GET[‘password‘];13 echo "現在的會話內容是:<br>";14 echo "使用者名稱:", $_SESSION[‘username‘], "<br/>";15 echo "密碼:", $_SESSION[‘password‘], "<br/>";16 ?>17 </body>18 </html>