אז מה לגבי עמוד הindex.php?
תן לי להראות לך את מה שאני בניתי (הקוד שלך בצורה יותר נוחה):
index.php - פאנל הניהול
PHP קוד:
<?php
session_start();
if ($_SESSION['login'] == "1")
{
?>
(TEST TEXT TEXT)
<?php
}
else
{
echo "אתה לא מחובר";
}
?>
login.php - טופס ההתחברות
PHP קוד:
<?php
session_start();
if (isset($_POST['next']))
{
test();
}
function test()
{
if ($_POST['username'] == "Admin" && $_POST['password'] == "1234")
{
$_SESSION['login'] = "1";
echo "<meta http-equiv='refresh' content='0;URL=panel.php' />";
}
else
{
echo "<center>שגיאה</center>";
}
}
if ($_SESSION['login'] == 1)
{
echo "<meta http-equiv='refresh' content='0;URL=panel.php' />";
}
else
{
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255" />
<title>Login</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
UserName:
<label>
<input type="text" name="username" id="username" />
</label>
<p>PassWord:
<label>
<input type="text" name="password" id="password" />
</label>
</p>
<p>
<label>
<input type="submit" name="next" id="next" value="Login" />
</label>
</p>
</form>
</body>
</html>
<?php
}
php?>
קרא את הקוד בעיון.
מקווה שהבנת =]