Beste tweakers, ik zit hier met een sessie probleem in php.
Het is als volgt.
Ik heb een pagina bestaande uit drie pagina's die geincluded worden (head, eigenpagina, foot).
In de head.php staat het volgende inlogformulier.
In me head.php start ie de ob_start(); en session_start(); op.
in de login.php staat het volgende:
Het volgende staat in me loginsuccesvol.php
Deze foutmelding krijg ik als ik ob_start(); weghaal uit me head.php
Warning: Cannot modify header information - headers already sent by (output started at c:\inetpub\wwwroot\pcaid\head.php:10) in c:\inetpub\wwwroot\pcaid\login.php on line 18
En deze krijg ik altijd:
Notice: Undefined variable: fout in c:\inetpub\wwwroot\pcaid\login.php on line 81
Wat ze betekenen weet ik wel, maar ik krijg ze met geen mogelijkheid weg
Iemand een idee
Thanks already
en mijn head.php file op verzoek
Het is als volgt.
Ik heb een pagina bestaande uit drie pagina's die geincluded worden (head, eigenpagina, foot).
In de head.php staat het volgende inlogformulier.
In me head.php start ie de ob_start(); en session_start(); op.
in de login.php staat het volgende:
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
| <?php include ("head.php"); //Maak mysql connectie include ("functions.php"); mysql_connection(); //get loginnaam en wachtwoord $inlognaam = $_POST['inlognaam']; $wachtwoord = md5 ($_POST['wachtwoord']); //Mysql query $query = "select inlognaam, wachtwoord from gebruikers where inlognaam = '$inlognaam' and wachtwoord = '$wachtwoord'"; $res = mysql_query($query); if (mysql_num_rows($res) == 1) { header("location: loginsuccesvol.php"); } else { $fout = ("Probeer het opnieuw. De gebruikersnaam en/of wachtwoord was onjuist."); } //Mysql query $query = "SELECT * FROM nieuws ORDER BY ID DESC LIMIT 5"; $result = mysql_query($query) or die ("Er ging iets fout."); ?> |
Het volgende staat in me loginsuccesvol.php
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
| <?php include ("head.php"); //Maak mysql connectie include ("functions.php"); mysql_connection(); $inlognaam = $_POST['inlognaam']; //Mysql query $query = "SELECT * FROM nieuws ORDER BY ID DESC LIMIT 5"; $result = mysql_query($query) or die ("Er ging iets fout."); ?> |
Deze foutmelding krijg ik als ik ob_start(); weghaal uit me head.php
Warning: Cannot modify header information - headers already sent by (output started at c:\inetpub\wwwroot\pcaid\head.php:10) in c:\inetpub\wwwroot\pcaid\login.php on line 18
En deze krijg ik altijd:
Notice: Undefined variable: fout in c:\inetpub\wwwroot\pcaid\login.php on line 81
Wat ze betekenen weet ik wel, maar ik krijg ze met geen mogelijkheid weg
Iemand een idee
Thanks already
en mijn head.php file op verzoek
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
| <?php ob_start(); session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>PCaid.nl</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-color: #F9F9F9; } --> </style> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <body onLoad="MM_preloadImages('layout/menu_home2nd.gif','layout/menu_forum2nd.gif','layout/menu_links2nd.gif','layout/menu_tarieven2nd.gif','layout/menu_contact2nd.gif')"> <table width="780" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="15" height="83">[img]"layout/head_left.gif"[/img]</td> <td width="203"><a href="index.php">[img]"layout/logo.gif"[/img]</a></td> <td width="562" background="layout/head_right.gif"> <?php //Kijken of men is ingelogd en zodoende de juiste tekst weergeven if(isset($_SESSION['inlognaam'])) { echo('<table width="200" border="0" align="right" cellpadding="0" cellspacing="0">'); echo('<tr>'); echo("<td>U bent ingelogd als <B>$inlognaam</B><br><br>"); echo('<a href="uitgelogd.php">Klik hier om uit te loggen</a></td>'); echo('</tr>'); echo('</table>'); } else { echo('<form action="login.php" method="post">'); echo('<table width="272" border="0" align="right" cellpadding="1" cellspacing="1">'); echo('<tr>'); echo('<td width="107" class="style3"><span class="style3">Gebruikersnaam:</span></td>'); echo('<td colspan="3"><input type="text" name="inlognaam"></td>'); echo('</tr>'); echo('<tr>'); echo('<td class="style3"><span class="style3">Wachtwoord:</span></td>'); echo('<td colspan="3"><input type="password" name="wachtwoord"></td>'); echo('</tr>'); echo('<tr><td> </td>'); echo('<td width="108">'); echo('<a href="registrerenform.php">Registreren</a></td>'); echo('<td width="32"><div align="right">'); echo('<input name="submit" type="image" value="inloggen" src="layout/button_go.gif">'); echo('</div></td>'); echo('<td width="12"> </td>'); echo('</tr>'); echo('</table>'); echo('</form>'); } ?> </td> </tr> </table> <table width="780" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td>[img]"layout/pixel_blue.gif"[/img][img]"layout/pixel_white.gif"[/img]<a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Home','','layout/menu_home2nd.gif',1)">[img]"layout/menu_home.gif"[/img]</a>[img]"layout/pixel_white.gif"[/img]<a href="registrerenform.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Forum','','layout/menu_forum2nd.gif',1)">[img]"layout/menu_forum.gif"[/img]</a>[img]"layout/pixel_white.gif"[/img]<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Links','','layout/menu_links2nd.gif',1)">[img]"layout/menu_links.gif"[/img]</a>[img]"layout/pixel_white.gif"[/img]<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Tarieven','','layout/menu_tarieven2nd.gif',1)">[img]"layout/menu_tarieven.gif"[/img]</a>[img]"layout/pixel_white.gif"[/img]<a href="contact.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Contact','','layout/menu_contact2nd.gif',1)">[img]"layout/menu_contact.gif"[/img]</a>[img]"layout/pixel_white.gif"[/img][img]"layout/pixel_blue.gif"[/img]</td> </tr> <tr> <td>[img]"layout/color_line.gif"[/img]</td> </tr> </table> </body> </html> |
[ Voor 92% gewijzigd door Tubbietje op 17-01-2005 16:06 ]
Intel Core i7 4770K + 8x LG 24EB23 | New iPad 16GB WiFi | Xiaomi Mi Mix 2 | Microsoft Surface Pro 3 i5 128GB