Below are the codes I wrote. I want to have password protection for my page which can only be seen by people with the correct password.
Of course something wrong with my codes.
Who can help me do it right? Thank you:D
code:
<?php
print <<<enterpassword
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<title>Please enter your password</title>
<meta http-equiv=“Content-Type”
content=“text/html; charset=utf-8” />
</head>
<body>
<h1>Hello, my friends! Welcome!!</h1>
<form method=“get” action=“aaa.php”>
<fieldset>
<legend>password protection</legend>
<p>
<label for=“password”>Please enter your password:</label>
<input type=“password” name=“password” id=“password” /><br /><br />
</p>
<label for=“text”>Please write your opinions:</label><br />
<p>
<textarea name=“text” rows=“9” cols:“11” id=“text” />
</p>
<p><input type=“submit” value=“Click and Submit”/></p>
</fieldset>
</form>
</body>
</html>
enterpassword;
if(password==‘abc’)
print <<<newpage
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<title>Welcome</title>
<meta http-equiv=“Content-Type”
content=“text/html; charset=utf-8” />
</head>
<body>
<h1>Welcome to my website!</h1>
</body>
</html>
newpage;
else {
<h1>Your password is incorrect!!<h1>
}
?>