-
-
Save summer10920/17d48d2e632974b2be2826b925d45b86 to your computer and use it in GitHub Desktop.
20200512-php-baseclass-7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//判斷國籍做簡單的問候 | |
switch ($_POST['country']) { | |
case 'tw': | |
echo "您好!" . $_POST['who']; | |
break; | |
case 'jp': | |
echo "空你鳩挖!" . $_POST['who']; | |
break; | |
case 'hk': | |
echo "雷侯!" . $_POST['who']; | |
break; | |
} | |
echo "<br>感謝您的註冊"; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// print_r($_POST); | |
if (!empty($_POST)) { | |
//判斷國籍做簡單的問候 | |
switch ($_POST['country']) { | |
case 'tw': | |
echo "您好!" . $_POST['who']; | |
break; | |
case 'jp': | |
echo "空你鳩挖!" . $_POST['who']; | |
break; | |
case 'hk': | |
echo "雷侯!" . $_POST['who']; | |
break; | |
} | |
echo "<br>感謝您的註冊"; | |
} | |
else{ | |
?> | |
<!--Form表單基本結構--> | |
<style> | |
.full { | |
width: 100% | |
} | |
</style> | |
<div style="margin:50px auto;width:20%"> | |
<h3 style="text-align:center"> | |
<hr>會員註冊 | |
<hr> | |
</h3> | |
<form method="post"> | |
帳號: | |
<input type="text" name="who" class="full"> | |
<br /><br /> | |
密碼: | |
<input type="password" name="pwd" class="full"> | |
<br /><br /> | |
生日: | |
<input type="date" name="birth" class="full"> | |
<br /><br /> | |
國籍: | |
<select name="country"> | |
<option value="tw" selected>台灣</option> | |
<option value="jp">日本</option> | |
<option value="hk">香港</option> | |
</select> | |
<br><br /> | |
性別: | |
<input type="radio" name="sex" value="man">男生 | |
<input type="radio" name="sex" value="woman">女生 | |
<br><br> | |
專長: | |
<input type="checkbox" name="skill[]" value="web">網頁開發 | |
<input type="checkbox" name="skill[]" value="art">平面設計 | |
<input type="checkbox" name="skill[]" value="rd">程式開發 | |
<br /><br /> | |
簡介:<br /><textarea name="aboutme" cols="30" rows="10" class="full"></textarea> | |
<br /><br /> | |
<input type="reset" value="重置"> | |
<input type="submit" value="送出"> | |
<input type="button" value="純按鈕" onclick="console.log('Hello World')"> | |
<!--通常被用在執行JS動作--> | |
<br /><br /> | |
隱藏:<input type="hidden" name="noshow" value="showit"> | |
<!--隱藏不顯示但存在--> | |
</form> | |
</div> | |
<?php | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--Form表單基本結構--> | |
<style> | |
.full { | |
width: 100% | |
} | |
</style> | |
<div style="margin:50px auto;width:20%"> | |
<h3 style="text-align:center"> | |
<hr>會員註冊 | |
<hr> | |
</h3> | |
<form method="post" action="1_submit_2.php"> | |
帳號: | |
<input type="text" name="who" class="full"> | |
<br /><br /> | |
密碼: | |
<input type="password" name="pwd" class="full"> | |
<br /><br /> | |
生日: | |
<input type="date" name="birth" class="full"> | |
<br /><br /> | |
國籍: | |
<select name="country"> | |
<option value="tw" selected>台灣</option> | |
<option value="jp">日本</option> | |
<option value="hk">香港</option> | |
</select> | |
<br><br /> | |
性別: | |
<input type="radio" name="sex" value="man">男生 | |
<input type="radio" name="sex" value="woman">女生 | |
<br><br> | |
專長: | |
<input type="checkbox" name="skill[]" value="web">網頁開發 | |
<input type="checkbox" name="skill[]" value="art">平面設計 | |
<input type="checkbox" name="skill[]" value="rd">程式開發 | |
<br /><br /> | |
簡介:<br /><textarea name="aboutme" cols="30" rows="10" class="full"></textarea> | |
<br /><br /> | |
<input type="reset" value="重置"> | |
<input type="submit" value="送出"> | |
<input type="button" value="純按鈕" onclick="console.log('Hello World')"> | |
<!--通常被用在執行JS動作--> | |
<br /><br /> | |
隱藏:<input type="hidden" name="noshow" value="showit"> | |
<!--隱藏不顯示但存在--> | |
</form> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//2_check.php | |
if(!empty($_POST)){ | |
if(($_POST['acc']!="admin") || ($_POST['pwd']!="1234")) { | |
echo "<script>alert('帳號錯誤')</script>"; | |
//echo "<script>document.location.href='2_login.php'</script>"; | |
//上面是JS轉址,下面是JS控制返回上頁的語法 | |
echo "<script>window.history.back()</script>"; | |
} | |
else{ | |
echo "<script>alert('歡迎 ".$_POST['acc']." 登入')</script>"; | |
echo "<script>document.location.href='https://www.google.com/'</script>"; | |
//如果只是轉址可以透過php,但如果需要JS的alert,你就不無法正常使用,因為還沒有alert就被PHP執行轉址了 | |
//header("location:https://www.google.com/"); | |
} | |
} | |
else{ | |
echo "<script>document.location.href='2_login.php'</script>"; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>會員登入</h3> | |
<form action="2_check.php" method="post"> | |
<p>帳號 | <input type="text" name="acc"></p> | |
<p>密碼 | <input type="password" name="pwd"></p> | |
<p><input type="submit" value="登入"></p> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!empty($_POST)){ | |
if(($_POST['acc']!="admin") || ($_POST['pwd']!="1234")) { | |
echo "<script>alert('帳號錯誤')</script>"; | |
//echo "<script>document.location.href='2_login.php'</script>"; | |
//上面是 JS 轉址,下面是 JS 控制返回上頁的語法 | |
echo "<script>window.history.back()</script>"; | |
} | |
else{ | |
echo "<script>alert('歡迎 ".$_POST['acc']." 登入')</script>"; | |
echo "<script>document.location.href='https://www.google.com/'</script>"; | |
//如果只是轉址可以透過 php,但如果需要 JS 的 alert,你就不無法正常使用,因為還沒有 alert 就被 PHP 執行轉址了 | |
//header("location:https://www.google.com/"); | |
} | |
} | |
else{ | |
echo "<script>document.location.href='2_login.php'</script>"; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>會員登入</h3> | |
<form action="hw_check.php" method="post"> | |
<p>帳號 | <input type="text" name="acc"></p> | |
<p>密碼 | <input type="password" name="pwd"></p> | |
<p><input type="submit" value="登入"></p> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment