25
五月

程式設計二程式 05/25: ex7

   Posted by: admin   in 103(下)程式設計(二)

//ex7-login.php

<?php

$message=”請輸入密碼”;

if(isset($_POST["Submit"])){

//

$Usename=$_POST["Usename"];

$Password=$_POST["Password"];

if ($Usename == “abc” && $Password ==”123″)

{

session_start();

$_SESSION['auth'] = true;//認證成功,設定一個session變數

header(’Location: ex7.php’);

exit;

}

else

{

$message=”帳號或密碼錯誤”;

}

}

?>

<form action=”ex7-login.php” method=”post”>

<table width=”200″ border=”1″>

<tr>

<td>帳號</td>

<td><input type=”text” name=”Usename” ></td>

<td><?php echo $message?> </td>

</tr>

<tr>

<td>密碼</td>

<td><input type=”password” name=”Password”></td>

<td><input type=”submit” name=”Submit” value=”登入” /></td>

</tr>

</table>

</form>

//ex7.php

<h1>ex7-登入/登出網站的PHP程式</h1>

<img src=”001-03.png” width=”974″ height=”150″ />

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

This entry was posted on 星期一, 五月 25th, 2015 at 10:25:18 and is filed under 103(下)程式設計(二). You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment