Sunteți pe pagina 1din 3

<html xmlns="http://www.w3.

org/1999/xhtml">

<head>

<title>Login Page</title>

</head>

<body>

<form method="post" action="process.php">

<h2>Login Page</h2>

<br />

<br />

User Name:

<br />

<input type="text" name="username" size="16" />

<br />

<br />

Password:

<br />

<input type="password" name="password" size="16" />

<br />

<br />

<br />

<br />

<input type="submit" value="submit" />

</form>

</body>
</html>

The second page is process.php

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title></title>

</head>

<body>

<?php

$passwords = array("bill" =>"apple", "charles" =>"potato", "david" =>"orange");

if ($password == $passwords[$username])

setcookie("username", $username, time()+1200);

echo "<h2>Access granted.</h2>";

else

setcookie("username", "", time()-1200);

echo "<h2>Invalid user name or password: access denied.</h2>";

}
?>

</body>

</html>

S-ar putea să vă placă și