Archive for 三月 9th, 2012

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

<?
$AuthMessage="請輸入帳號資料";
if(isset($_POST["Submit"])){
	//
	$EmailAddress=$_POST["Email"];
	$Pop3Password=$_POST["Password"];
	if ($EmailAddress == "www@asia.edu.tw" && $Pop3Password =="1234")
	{
		if(isset($_SESSION["UrlRedirect"]))
		{
			$redir = $_SESSION["UrlRedirect"];
		}
		else
		{
			$redir = 'ex3-1.php';
		}
	//
		session_register('authenticated');
		$_SESSION['authenticated'] = true;
		header("Location: $redir");
		exit;
	}
	else
	{
	$AuthMessage="認證失敗";
	}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>Ex3-2</title>
<script language="JavaScript">
function checkemail(){
var str=document.myform.Email.value;
if (isValidEmail(str))
{
return true;
}
else{
alert("Please input a valid email address!");
return false;
}
}
function isValidEmail(str) {
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
</script>
</head>
<body>
<form name="myform" method="POST" action="ex3-2.php" onSubmit="return
checkemail()">
使用學校EMail 帳號認證
<table border="1" width="300">
<tr>
<td>Email帳號</td>
<td><input type="text" name="Email" size="20"></td>
</tr>
<tr>
<td>密碼</td>
<td><input type="password" name="Password" size="20"></td>
</tr>
</table>
<p>
<input type="submit" value="送出" name="Submit">
<input type="reset" value="重新設定" name="B2">
</p>
</form>
<?
echo $AuthMessage;
?>
</body>
</html>

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

<?
session_start();
session_unset();
session_destroy();
header('Location: ex3-2.php');
exit;
?>

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

<?
session_start();
session_register('UrlRedirect');
$_SESSION['UrlRedirect'] = $PHP_SELF;
if(empty($_SESSION['authenticated'])||$_SESSION['authenticated']==false)
{
	header('Location: ex3-2.php');
	exit;
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ex3-1</title>
</head>
 
<body>
<form method="post" action="ex3-3.php">
<input type="submit" name="submit" value="登出">
</form>
 
<img src="pic.jpg" width="667" height="132" />
</body>
</html>

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,