0325
使用xampp建設後端環境
打開後
General -> Start
Services -> Apache、MySQL、ProFTPD -> Start
Network -> localhost:8080->80(Over SSH) -> Enable
Volumes -> Mount
Volumes -> Explore -> lampp -> htdocs -> 創建一個資料夾(eg:yeee) -> 創建一個php檔(eg:index.php 輸入程式碼)
開瀏覽器 -> 輸入http://localhost:8080/yeee/index.php 會顯示資料
php
<?php
for($i = 0; $i < 10; $i++){
echo '<li>'.$i.'</li>';
}
?>
- 利用isset()來檢查有無此變數
- 利用$_GET來存到你想要的東西
<?php
$username='';
if(isset($_GET['username'])){
$username = $_GET['username'];
}
echo 'username:'.$username.'<br>';
if($username === 'admin'){
echo 'hello admin!';
}else{
echo 'fail';
}
?>
url輸入http://localhost:8080/yeee/index.php?username=admin 會顯示
username:admin
hello admin!
0325
使用xampp建設後端環境
打開後
General -> Start
Services -> Apache、MySQL、ProFTPD -> Start
Network -> localhost:8080->80(Over SSH) -> Enable
Volumes -> Mount
Volumes -> Explore -> lampp -> htdocs -> 創建一個資料夾(eg:yeee) -> 創建一個php檔(eg:index.php 輸入程式碼)
開瀏覽器 -> 輸入http://localhost:8080/yeee/index.php 會顯示資料
php
url輸入http://localhost:8080/yeee/index.php?username=admin 會顯示
username:admin
hello admin!
url輸入http://localhost:8080/yeee/index.php 會出現帳密輸入框
username填admin,password填admin就會登入成功並輸出username,其他則登入失敗,若頁面分離則登入失敗時會跳回index.php