Er is een html pagina waarvan ik een usrname + wachtwoord door krijg. Hieruit dient een sessie opgebouwd te worden. Alvorens moet gecontroleerd worden of er al een sessie bestaat onder deze username. Is dat niet zo dient hij aangemaakt te worden, dit blijkt niet te werken.
Ik ben nog neit zo lang bezig met PHP, dus als iemand tips heeft voor het verbeteren van de code, ik ben geinterreseerd.
De foutmelding die ik krijg is:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /usr/local/slash/apache/vhosts/preadict.nl/httpdocs/php/authenticate.php:5) in /usr/local/slash/apache/vhosts/preadict.nl/httpdocs/php/authenticate.php on line 7
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/local/slash/apache/vhosts/preadict.nl/httpdocs/php/authenticate.php:5) in /usr/local/slash/apache/vhosts/preadict.nl/httpdocs/php/authenticate.php on line 7
Warning: Cannot modify header information - headers already sent by (output started at /usr/local/slash/apache/vhosts/preadict.nl/httpdocs/php/authenticate.php:5) in /usr/local/slash/apache/vhosts/preadict.nl/httpdocs/php/authenticate.php on line 12
modbreak:
Volgende keer even nadenken voor je zomaar wat inloggegevens post
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
39
40
41
42
43
| session_start(); //Bestaat er al een sessie? if(!session_is_registered("gebruiksnaam")) {header("Location: Test4.html"); exit;} else //Controleren of de persoon die inlogt ook wel daadwerkelijk toegang heeft if(authenticated($login,$ww)) {header("Location: Test4.html"); exit;} else echo "Je wachtwoord of login klopt niet!"; function authenticated($login, $ww) { $link = mysql_connect("localhost", "preadictor", "********") or die ("Could not connect"); mysql_select_db("preadict_sys"); if(!isset($login) || !isset($ww)) return false; if($login == $ww) return false; $tijdelijk = mysql_fetch_array(mysql_query("SELECT GEBRUIKERSNAAM FROM HELPDESK_GEBRUIKERS WHERE GEBRUIKERSNAAM = \"$login\" AND WACHTWOORD =\"$ww\"")); $temp=$tijdelijk[GEBRUIKERSNAAM]; if($login==$temp) {return true; session_register("gebruikersnaam"); session_register("wachtwoord"); $gebruikersnaam=$login; $wachtwoord=$ww;} else {return false;} } |
Ik ben nog neit zo lang bezig met PHP, dus als iemand tips heeft voor het verbeteren van de code, ik ben geinterreseerd.
De foutmelding die ik krijg is:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /usr/local/slash/apache/vhosts/preadict.nl/httpdocs/php/authenticate.php:5) in /usr/local/slash/apache/vhosts/preadict.nl/httpdocs/php/authenticate.php on line 7
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/local/slash/apache/vhosts/preadict.nl/httpdocs/php/authenticate.php:5) in /usr/local/slash/apache/vhosts/preadict.nl/httpdocs/php/authenticate.php on line 7
Warning: Cannot modify header information - headers already sent by (output started at /usr/local/slash/apache/vhosts/preadict.nl/httpdocs/php/authenticate.php:5) in /usr/local/slash/apache/vhosts/preadict.nl/httpdocs/php/authenticate.php on line 12
modbreak:
Volgende keer even nadenken voor je zomaar wat inloggegevens post
[ Voor 7% gewijzigd door Janoz op 28-11-2003 15:36 ]