דומה מאוד למה שאני עשיתי
PHP קוד:
<?php
// מיקום הדף בו נמצאת הסיסמא
// דוגמא
// http://www.site.co.il/serial.php
$file = "";
// פונקציה שמראה את תוכן הדף
function pagecontent()
{
echo "
<div align=\"center\">
אתגר תיכנות פורום הוסטס
</div>
";
}
// עיצוב הדף
echo "
<!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>Hosts.co.il</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1255\" />
<style type=\"text/css\">
body
{
font-family: Arial;
font-size: 11px;
}
input
{
border-right: #eeeeee 1px solid;
padding-right: 0px;
border-top: #eeeeee 1px solid;
padding-left: 0px; font-size: 9pt;
padding-bottom: 0px;
border-left: #eeeeee 1px solid;
padding-top: 0px;
border-bottom: #eeeeee 1px solid;
font-family: Arial;
background: #f5f5f5;
font-size: 11px;
}
td
{
font-family: Arial;
font-size: 11px;
color: #0a2d4d;
}
</style>
</head>
<body>
<div align=\"center\">
<form action=\"index2.php\" method=\"post\">
<table>
<tr>
<td><input type=\"hidden\" name=\"posted\" value=\"\" /></td>
</tr>
<tr>
<td align=\"center\">:סיסמת גישה לקובץ</td>
</tr>
<tr>
<td align=\"center\"><input type=\"text\" name=\"serial\" value=\"\" /></td>
</tr>
<tr>
<td align=\"center\"><input type=\"submit\" value=\"בדוק\" /></td>
</tr>
</table>
</form>
</div>
</body>
</html>
";
// בדיקה אם נשלח הטופס ואם הסיסמא שנקלטה שווה לסיסמא שבקובץ
if(isset($_POST['posted']))
{
$file = file_get_contents($file);
if($_POST['serial'] == $file)
{
echo "<div align=\"center\"><font style=\"color: green; font-size: 11px; font-family: arial;\">הגישה אושרה</font></div>";
pagecontent();
}
else
{
echo "<div align=\"center\"><font style=\"color: red; font-size: 11px; font-family: arial;\">הגישה נדחתה</font></div>";
}
}
?>