View Single Post
ישן 20-07-08, 18:38   # 1
kfir91
חסום
 
מיני פרופיל
תאריך הצטרפות: Apr 2007
הודעות: 220

kfir91 לא מחובר  

שגיאה עם קוקיס ו headers

זה השגיאה :
קוד:
Warning: Cannot modify header information - headers already sent by (output started
זה הקוד :
קוד:
<html dir="rtl">
<head>
	<title>דף ראשי</title>
	<? include "config.php"; ?>
</head>
<body>

<?
$hour = time() + 3600;
$username = $_COOKIE['user'];
$password = $_COOKIE['pass'];

if(!isset($_COOKIE['user']))
    {
    echo "אתה אינך מחובר :: <a href=\"?act=loginform\">התחברות</a><br />";
    }
else
    echo "ברוך הבא $username :: <a href=\"?act=logout\">התנתק</a><br />";

$act = $_GET['act']; // הגדרת משתנה ראשי

if ($act == "logincheck") // בדיקת התחברות
{
// הכנסת פרטי הטופס למשתנים
$user = $_POST['User'];
$pass = $_POST['Pass'];

// בדיקת טופס

echo "
	<table class=\"loginchecktable\">
	<tr><td valign=\"top\" dir=\"rtl\" class=\"login_check_td_table\">";

	if ($pass == "")
	{
	   echo "סיסמא לא הוזנה";
	   echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=?act=loginform\">";
	}
	else if ($user == "")
	{
	   echo "שם משתמש לא הוזן";
	   echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=?act=loginform\">";
	}
	else
	{
	$s = mysql_query("SELECT * FROM members WHERE username='$user' && password='$pass'") or die(mysql_error());
	$checkform = mysql_num_rows($s);

		if ($checkform == "0")
		{
		echo "אחד מהפרטים אינו נכון";
		echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=?act=loginform\">";
		}
		else
		{
		   echo "התחברת בהצלחה";
		   setcookie(user, $user, $hour);
		   setcookie(pass, $pass, $hour);
		   echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=index.php\">";
		}
	}

echo "</td></tr>";
echo "</table>";
}

else if ($act =="loginform") // טופס התחברות
{
if(!isset($_COOKIE['user']))
{
echo <<<LOGINFORM

<form action="?act=logincheck" method="post"> 
<table class="logintable">

	<tr><td valign="top" dir="rtl" class="logintdtable">שם משתמש: </td>
	<td valign="top" dir="rtl" class="logintdtable"><input type="text" name="User"></td>
	</tr>
	<tr><td valign="top" dir="rtl" class="logintdtable">סיסמא:  </td>
	<td valign="top" dir="rtl" class="logintdtable"><input type="password" name="Pass"></td>
	</tr>
	<tr><td valign="top" dir="rtl" class="logintdtable"></td>
	<td valign="top" dir="rtl" class="logintdtable"><input type="reset" value="נקה"><input type="submit" value="התחבר"></td>
	</tr>
</table>
</form>  

LOGINFORM;
}
else
   {
   echo "אתה מחובר למערכת";
   echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=index.php\">";
   }
}

else if($act == "logout")
{
   $past = time() - 100;
   setcookie(user, gone, $past); 
   setcookie(pass, gone, $past); 
   echo "התנתקת בהצלחה";
   echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=index.php\">";
}

?>

</body>
</html>
הבעיה היא בשורות :
קוד:
		   setcookie(user, $user, $hour);
		   setcookie(pass, $pass, $hour);
  Reply With Quote