שימוש בסשנס צריך להיות לפני הכל, לפני הHEADERS (תגיות הפתיחה).
הקוד שלך אמור להיות:
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>";
}
}
?>
<!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>
אגב, ערכתי לך את הקידוד (הוא לא עברי, ואתה רוצה להציג טקסט בעברית).
לקריאה נוספת על סשנס, הייתי מציע לך לעיין פה:
http://php.eitan.ac.il/main.php?id=00169