Waarom geef ie deze error?
De fouten zijn:
Warning: Cannot modify header information - headers already sent by (output started at /usr/home/fh2028/domains/tdkclan.com/public_html/sites/Clantemp1/calender/login.php:9) in /usr/home/fh2028/domains/tdkclan.com/public_html/sites/Clantemp1/calender/login.php on line 25
Warning: Cannot modify header information - headers already sent by (output started at /usr/home/fh2028/domains/tdkclan.com/public_html/sites/Clantemp1/calender/login.php:9) in /usr/home/fh2028/domains/tdkclan.com/public_html/sites/Clantemp1/calender/login.php on line 26
Successful Login.
De code staat hier onder:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!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>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?PHP
include('functions.php'); // This includes the database functions i made for the database.
$username = $_POST['Username']; // Get the username sent from the form.
$password = $_POST['Password']; // Get the password sent from the form.
$md5_password = md5($password); // MD5 Hash the password, for extra security.
$page_rank = 1; // The rank of this page. Using 1 as admin, but you can change this as long as you change the
// database to reflect the change.
Connect(); // Connect to the database.
$sql = "SELECT rank FROM users WHERE username = '$username' AND password = '$md5_password' AND rank = '$page_rank' LIMIT 0,1";
$query = mysql_query($sql);
if(mysql_num_rows($query) == 1){
$row = mysql_fetch_row($query);
setcookie('AdmUsername', $username, time()+60*60*24*30, '/', '', 0);
setcookie('AdmRank', $row[0], time()+60*60*24*30, '/', '', 0);
echo('<strong>Successful Login.</strong><br />'.chr(10));
} else {
echo('<strong>Login Failed.</strong><br />'.chr(10));
}
Disconnect(); // Disconnect from the database.
?>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?PHP
include('functions.php'); // This includes the database functions i made for the database.
$username = $_POST['Username']; // Get the username sent from the form.
$password = $_POST['Password']; // Get the password sent from the form.
$md5_password = md5($password); // MD5 Hash the password, for extra security.
$page_rank = 1; // The rank of this page. Using 1 as admin, but you can change this as long as you change the
// database to reflect the change.
Connect(); // Connect to the database.
$sql = "SELECT rank FROM users WHERE username = '$username' AND password = '$md5_password' AND rank = '$page_rank' LIMIT 0,1";
$query = mysql_query($sql);
if(mysql_num_rows($query) == 1){
$row = mysql_fetch_row($query);
setcookie('AdmUsername', $username, time()+60*60*24*30, '/', '', 0);
setcookie('AdmRank', $row[0], time()+60*60*24*30, '/', '', 0);
echo('<strong>Successful Login.</strong><br />'.chr(10));
} else {
echo('<strong>Login Failed.</strong><br />'.chr(10));
}
Disconnect(); // Disconnect from the database.
?>
</body>
</html>
Mvg Jens
Gewijzigd op 01/01/1970 01:00:00 door Jens V
Mvg Jens'
staat dus niet in de code... :p
Het setten van een cookie moet vóór html output van de browser.
dus die <body> tag en alles erboven moet achter de php komen?
@ Jens: en niet bumpen, zoals ik je gisteren heb uitgelegd. Gebruik de edit-knop.
FAQ.
Edit
Zo, 3 reacties er nog tussen :s Voortaan even sneller typen :P
Gebruik je edit knopje, typ met kleine letters en lees de Edit
Zo, 3 reacties er nog tussen :s Voortaan even sneller typen :P
Gewijzigd op 01/01/1970 01:00:00 door Willem Jan Z
Jan:
@ Jens: en niet bumpen, zoals ik je gisteren heb uitgelegd. Gebruik de edit-knop.
deed ik, maar toen ik zag dat de code weer niet werkte poste ik een reply (eigenlijk vervolg..)
moest edit hebben maar deed dus quote!
EDIT, merci, werkt:)
Gewijzigd op 01/01/1970 01:00:00 door Jens V
deze error:
Warning: Cannot modify header information - headers already sent by (output started at /usr/home/fh2028/domains/tdkclan.com/public_html/sites/Clantemp1/calender/functions.php:36) in /usr/home/fh2028/domains/tdkclan.com/public_html/sites/Clantemp1/calender/login.php on line 17
Warning: Cannot modify header information - headers already sent by (output started at /usr/home/fh2028/domains/tdkclan.com/public_html/sites/Clantemp1/calender/functions.php:36) in /usr/home/fh2028/domains/tdkclan.com/public_html/sites/Clantemp1/calender/login.php on line 18
Successful Login.
en dit is nu de login.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?PHP
include('functions.php'); // This includes the database functions i made for the database.
$username = $_POST['Username']; // Get the username sent from the form.
$password = $_POST['Password']; // Get the password sent from the form.
$md5_password = md5($password); // MD5 Hash the password, for extra security.
$page_rank = 1; // The rank of this page. Using 1 as admin, but you can change this as long as you change the
// database to reflect the change.
Connect(); // Connect to the database.
$sql = "SELECT rank FROM users WHERE username = '$username' AND password = '$md5_password' AND rank = '$page_rank' LIMIT 0,1";
$query = mysql_query($sql);
if(mysql_num_rows($query) == 1){
$row = mysql_fetch_row($query);
setcookie('AdmUsername', $username, time()+60*60*24*30, '/', '', 0);
setcookie('AdmRank', $row[0], time()+60*60*24*30, '/', '', 0);
echo('<strong>Successful Login.</strong><br />'.chr(10));
} else {
echo('<strong>Login Failed.</strong><br />'.chr(10));
}
Disconnect(); // Disconnect from the database.
?>
<!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>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
</body>
</html>
include('functions.php'); // This includes the database functions i made for the database.
$username = $_POST['Username']; // Get the username sent from the form.
$password = $_POST['Password']; // Get the password sent from the form.
$md5_password = md5($password); // MD5 Hash the password, for extra security.
$page_rank = 1; // The rank of this page. Using 1 as admin, but you can change this as long as you change the
// database to reflect the change.
Connect(); // Connect to the database.
$sql = "SELECT rank FROM users WHERE username = '$username' AND password = '$md5_password' AND rank = '$page_rank' LIMIT 0,1";
$query = mysql_query($sql);
if(mysql_num_rows($query) == 1){
$row = mysql_fetch_row($query);
setcookie('AdmUsername', $username, time()+60*60*24*30, '/', '', 0);
setcookie('AdmRank', $row[0], time()+60*60*24*30, '/', '', 0);
echo('<strong>Successful Login.</strong><br />'.chr(10));
} else {
echo('<strong>Login Failed.</strong><br />'.chr(10));
}
Disconnect(); // Disconnect from the database.
?>
<!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>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
</body>
</html>
wat nu? :/
Gewijzigd op 01/01/1970 01:00:00 door Jens V
Een stoplap is ob_start () aan het begin van je script en ob_end_flush () aan het einde van je script, maar het is netter om eerst alle logica af te handelen voordat je iets terugstuurt naar de browser.
Dit is functions.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?PHP
// Database Functions.
function Connect(){
# The Database Host. #
# Localhost is default. #
$database_HOST = 'xxxxx';
# The Database Username. #
# Root is the default. #
$database_USERNAME = 'xxxxxx';
# The Database Password. #
$database_PASSWORD = 'xxxxx';
# The Database Name. #
$database_NAME = 'xxxxxx';
if(!@mysql_connect($database_HOST, $database_USERNAME, $database_PASSWORD)){
$error = "Connection Error!<br />";
return $error;
}
if(!@mysql_select_db($database_NAME)){
$error = "Database Selection Error<br />";
return $error;
}
return FALSE;
}
function Disconnect(){
if(!@mysql_close()){
echo('Could not close database connection.');
}
}
?>
// Database Functions.
function Connect(){
# The Database Host. #
# Localhost is default. #
$database_HOST = 'xxxxx';
# The Database Username. #
# Root is the default. #
$database_USERNAME = 'xxxxxx';
# The Database Password. #
$database_PASSWORD = 'xxxxx';
# The Database Name. #
$database_NAME = 'xxxxxx';
if(!@mysql_connect($database_HOST, $database_USERNAME, $database_PASSWORD)){
$error = "Connection Error!<br />";
return $error;
}
if(!@mysql_select_db($database_NAME)){
$error = "Database Selection Error<br />";
return $error;
}
return FALSE;
}
function Disconnect(){
if(!@mysql_close()){
echo('Could not close database connection.');
}
}
?>
Gewijzigd op 01/01/1970 01:00:00 door Jens V
Er zit maar 1 echo statement in dat bestand, dus waarschijnlijk gaat het daar fout.
EDIT:
'k Heb de echo weggehaald, en ze zegt nog steeds hetzelfde
Gewijzigd op 01/01/1970 01:00:00 door Jens V
Probeer dan die tip maar uit met ob_start enz die ik al eerder gaf.
De andere vraag, die van gisteren, kunnen we daar nu nog even naar kijken?
URL= http://www.phphulp.nl/forum/showtopic.php?id=20564&cat=12&replies=40