Toon posts:

[php] session error?

Pagina: 1
Acties:
  • 38 views sinds 30-01-2008

Verwijderd

Topicstarter
Hallo,

Weet iemand misschien waarom ik de volgende error's krijg:

Warning: Cannot send session cookie - headers already sent by (output started at /home/sites/site102/web/school/login.php:6) in /home/sites/site102/web/school/login.php on line 33

Warning: Cannot send session cache limiter - headers already sent (output started at /home/sites/site102/web/school/login.php:6) in /home/sites/site102/web/school/login.php on line 33

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
36
37
38
<?
require("../includes/config.php");
?>
<html> 
<head> 
   <title><?=$Sitenaam?> - Login</title> 
</head> 
<?=$body?>
<center><h3>Login</h3> 
<form action="login.php" method="post"> 
  Gebruikersnaam:<br> 
<input type="hidden" name="Submit" value="1"> 
  <input type="Text" name="gebruikersnaam"><p> 
  Wachtwoord:<br> 
  <input type="Password" name="wachtwoord"><p> 
  <input type="Submit" value="Login!"> 
</form> 
</center>
<?php
require("../includes/mysql.php");
If ($Submit) {  
$HTTP_POST_VARS['gebruikersnaam'] = addslashes($HTTP_POST_VARS['gebruikersnaam']);  
$HTTP_POST_VARS['$wachtwoord'] = addslashes($HTTP_POST_VARS['wachtwoord']);  
$Query = mysql_query("SELECT * FROM gebruikers WHERE  
gebruikersnaam = '$HTTP_POST_VARS[gebruikersnaam]' AND password = '$HTTP_POST_VARS[wachtwoord]'");  
$Results = mysql_num_rows($Query);  
if ($Results == '1') {  
$TEST->Login = 1;  
$TEST->Username = "$HTTP_POST_VARS[gebruikersnaam]";  
$TEST->Password = "$HTTP_POST_VARS[wachtwoord]";  
session_register("TEST");  
echo " Je bent ingelogd als $TEST->Username .n";  
}  
else {  
        print "Je gebruikersnaam of wachtwoord klopt niet. Probeer het opnieuw. n";  
     }  
} 
?>

  • Tux
  • Registratie: Augustus 2001
  • Laatst online: 21-08 06:33

Tux

Je mag geen output hebben voor sessie functies.

Dus je sessie functies moet helemaal aan het begin van het script voor alle html-codes.

Een beetje zoeken kan trouwens ook.

[ Voor 13% gewijzigd door Tux op 07-04-2003 17:33 ]

The NS has launched a new space transportation service, using German trains which were upgraded into spaceships.


  • Glimi
  • Registratie: Augustus 2000
  • Niet online

Glimi

Designer Drugs

(overleden)
Zie Tux: Output buffering is je vriend :)

En lees ook http://www.php.net/manual/en/ref.session.php nog even door. Dan snap je precies waarom je geen output mag sturen voordat je een sessie start :)
Succes ermee :)

  • whoami
  • Registratie: December 2000
  • Laatst online: 23:02
Zie de reply van Tux.

Er zijn al veel topics over dit probleem langsgeweest. Ff de search gebruiken (en de error msg interpreteren).
Succes.

https://fgheysels.github.io/


Dit topic is gesloten.