הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   שגיאה בקובץ התחברות ( PHP ) (https://hosts.co.il/forums/showthread.php?t=42659)

username1 02-04-07 12:46

שגיאה בקובץ התחברות ( PHP )
 
הקובץ מכיל את הקוד הנ"ל:

PHP קוד:

<center><font face=arial size=3>
<? 
include "includes/config.php";
include 
"includes/includes/db.php";

$submit $_POST['submit'];
$username $_POST['username'];
$password $_POST['password'];

if(
$submit) {
$sql 
SELECT * 
FROM members WHERE 1 
AND username = '$username' 
AND password = '$password' 
"

    
$result mysql_query($sql) or die("בעייה : " mysql_error()); 
    while (
$row mysql_fetch_array($result)) { 
        
$username $row["username"]; 
        
$password $row["password"];
        
$id $row["id"];
        }
if(!
mysql_num_rows($result)) {
echo 
"שם משתמש או סיסמה שגויים";
exit();
}

    
setcookie("user"$username,time() + 3600);
    
setcookie("pw"$passwordtime() + 3600);
    
setcookie("id"$idtime() + 3600);
echo 
"<meta http-equiv='refresh' content='5; url=index.php'>";
}
?> </center></font>

והשגיאה:
ציטוט:

Warning: Cannot modify header information - headers already sent by
אשמח לעזרה.

Gal Shafrir 02-04-07 12:49

תוסיף בתחילת הקוד:

PHP קוד:

ob_start(); 

ובסוף הקוד:

PHP קוד:

ob_end_flush(); 


username1 02-04-07 12:53

עדיין שגיאה.

Gal Shafrir 02-04-07 12:59

התכוונתי לפני ה center וה-font, ואחרי הסגירה שלהם.

username1 02-04-07 13:03

זה מה שעשיתי.. עדיין שגיאה
PHP קוד:

<center><font face=arial size=3>
<? 
ob_start
();
include 
"includes/config.php";
include 
"includes/includes/db.php";

$submit $_POST['submit'];
$username $_POST['username'];
$password $_POST['password'];

if(
$submit) {
$sql 
SELECT * 
FROM members WHERE 1 
AND username = '$username' 
AND password = '$password' 
"

    
$result mysql_query($sql) or die("בעייה : " mysql_error()); 
    while (
$row mysql_fetch_array($result)) { 
        
$username $row["username"]; 
        
$password $row["password"];
        
$id $row["id"];
        }
if(!
mysql_num_rows($result)) {
echo 
"שם משתמש או סיסמה שגויים";
exit();
}

    
setcookie("user"$username,time() + 3600);
    
setcookie("pw"$passwordtime() + 3600);
    
setcookie("id"$idtime() + 3600);
echo 
"<meta http-equiv='refresh' content='5; url=index.php'>";
}
ob_end_flsuh();
?> </center></font>


Meir 02-04-07 13:10

אתה צריך לשים את הob_start לפני הכל

PHP קוד:

<? ob_start(); ?>
<center><font face=arial size=3>
<? 
include "includes/config.php";
include 
"includes/includes/db.php";

$submit $_POST['submit'];
$username $_POST['username'];
$password $_POST['password'];

if(
$submit) {
$sql 
SELECT * 
FROM members WHERE 1 
AND username = '$username' 
AND password = '$password' 
"

    
$result mysql_query($sql) or die("בעייה : " mysql_error()); 
    while (
$row mysql_fetch_array($result)) { 
        
$username $row["username"]; 
        
$password $row["password"];
        
$id $row["id"];
        }
if(!
mysql_num_rows($result)) {
echo 
"שם משתמש או סיסמה שגויים";
exit();
}

    
setcookie("user"$username,time() + 3600);
    
setcookie("pw"$passwordtime() + 3600);
    
setcookie("id"$idtime() + 3600);
echo 
"<meta http-equiv='refresh' content='5; url=index.php'>";
}
?> </center></font>
<? ob_end_flsuh(); ?>


Matchs 02-04-07 13:12

זה flush..

username1 02-04-07 13:16

תיקנתי, ועדיין שגיאה של
ציטוט:

Warning: Cannot modify header information - headers already sent by

חיים 02-04-07 13:21

כי זה שולח לך תוכן תמחק את זה:<center><font face=arial size=3>

Eran-s 02-04-07 13:24

אתה מאנקלד את הקובץ הזה בקובץ אחר?


כל הזמנים הם GMT +2. הזמן כעת הוא 14:55.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ