Skip to content

Instantly share code, notes, and snippets.

@tony1223
Created September 29, 2012 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tony1223/3804422 to your computer and use it in GitHub Desktop.
Save tony1223/3804422 to your computer and use it in GitHub Desktop.
鐵人賽第六天說明資料
<?php
//因為要使用 session,所以需要先讓 php 進行起始的動作。
session_start();
?><html>
<head>
<title>表單練習</title>
</head>
<body>
<?php
if (isset($_SESSION["login"] )){
echo "歡迎登入, ".$_SESSION["login"]." !";
}else if(isset($_POST["account"])){
if(
$_POST["account"] == "test"
&& $_POST["password"] =="1234"
){
echo "歡迎登入, test !";
$_SESSION["login"] = "test";
}else{
echo "帳號或密碼輸入錯誤";
}
}else{ ?>
<form method="POST">
<p>請輸入帳號 <input type="text" name="account" /> </p>
<p>請輸入密碼 <input type="password" name="password" /> </p>
<p><input type="submit" value="送出" /></p>
</form>
<?php } ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment