標籤:
1. 功能說明:
index.php自動作出選擇.
如果沒有傳入參數,則載入 form.html.php; 如果有傳入參數(並且有參數firstName), 則載入welcome.html.php顯示姓名.
本人, 還在學習的初級階段, 如果你已然入門或是牛人, 請自動略過本文, 寫這些純粹是為了加深學習印象, 不是乾貨, 見諒…
2. 郊果:
初始介面:
跳轉介面:
3. 目錄welcome下一共有如下三個檔案,預設載入 index.php:
index.php
form.html.php
welcome.html.php
4. 代碼
index.php
<?php if (!isset($_REQUEST[‘firstName‘])) { include ‘form.html.php‘; } else { $firstName = $_REQUEST[‘firstName‘]; $lastName = $_REQUEST[‘lastName‘]; $output = ‘Welcome to our website, ‘ .htmlspecialchars($firstName, ENT_QUOTES, ‘UTF-8‘) .‘ ‘ .htmlspecialchars($lastName, ENT_QUOTES, ‘UTF-8‘) .‘!‘; include ‘welcome.html.php‘; }
form.html.php
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Input Name</title></head><body> <form action="" method="post"> <div> <label for="firstName">First Name: <input type="text" name="firstName" id="firstName"> </label> </div> <div> <label for="lastName">Last Name: <input type="text" name="lastName" id="lastName"> </label> </div> <div> <input type="submit" value="GO"> </div> </form></body></html>
welcome.html.php
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Form example</title></head><body> <p> <?php echo $GLOBALS[‘output‘]; ?> </p></body></html>
MySQL_PHP學習筆記_2015_0906_使用PHP模板