Ik ben bezig met een website in PHP waarbij je ook kan in & uitloggen. Nu lukt het aardig, maar zodra ik uitlog krijg ik de volgende errors:
Screenshot
http://b2f.hncf.nl/help.JPG
----------------------------------------------------------
Warning: Cannot modify header information - headers already sent by (output started at /home/hncfnl/public_html/b2f/test/index.php:2) in /home/hncfnl/public_html/b2f/test/uitloggen.php on line 5
Warning: Cannot modify header information - headers already sent by (output started at /home/hncfnl/public_html/b2f/test/index.php:2) in /home/hncfnl/public_html/b2f/test/uitloggen.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at /home/hncfnl/public_html/b2f/test/index.php:2) in /home/hncfnl/public_html/b2f/test/uitloggen.php on line 7
Warning: Cannot modify header information - headers already sent by (output started at /home/hncfnl/public_html/b2f/test/index.php:2) in /home/hncfnl/public_html/b2f/test/uitloggen.php on line 9
----------------------------------------------------------
De volgende codes gebruik ik:
----------------------------------------------------------
Index.php
----------------------------------------------------------
----------------------------------------------------------
Inloggen.php
----------------------------------------------------------
----------------------------------------------------------
uitloggen.php
----------------------------------------------------------
----------------------------------------------------------
global.inc.php
----------------------------------------------------------
Screenshot
http://b2f.hncf.nl/help.JPG
----------------------------------------------------------
Warning: Cannot modify header information - headers already sent by (output started at /home/hncfnl/public_html/b2f/test/index.php:2) in /home/hncfnl/public_html/b2f/test/uitloggen.php on line 5
Warning: Cannot modify header information - headers already sent by (output started at /home/hncfnl/public_html/b2f/test/index.php:2) in /home/hncfnl/public_html/b2f/test/uitloggen.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at /home/hncfnl/public_html/b2f/test/index.php:2) in /home/hncfnl/public_html/b2f/test/uitloggen.php on line 7
Warning: Cannot modify header information - headers already sent by (output started at /home/hncfnl/public_html/b2f/test/index.php:2) in /home/hncfnl/public_html/b2f/test/uitloggen.php on line 9
----------------------------------------------------------
De volgende codes gebruik ik:
----------------------------------------------------------
Index.php
PHP:
1
2
3
4
5
6
7
8
9
10
| <?php include("global.inc.php"); if($ingelogd == 1){ Echo "|| <a href='?page=wijzigen.php'>Profiel wijzigen</a> || <a href='?page=wwwijzigen.php'>wachtwoord wijzigen</a> || <a href='?page=pm.php'>Inbox</a> || <a href='?page=pm.php&actie=opstellen'>Nieuw Bericht(PM)</a> || <a href='?page=aanwezigheid.php'>Aanwezig (Training/WARs)</a> ||<br><br>"; } if(empty($page)) $page='nieuws.php'; if(!is_file($page)) $page=$page.'.php'; if(!is_file($page)) $page='nieuws.php'; include($page); ?> |
----------------------------------------------------------
----------------------------------------------------------
Inloggen.php
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
| <?php ob_start(); include_once("global.inc.php"); if($ingelogd == 1){ Echo "U bent al ingelogt!"; } else { if(isset($_GET['actie']) AND $_GET['actie'] == "controleren"){ $fout = ""; if(empty($_POST['nickname'])){ $fout.="Er is <i>geen</i> nickname ingevoerd.<br>"; } if(empty($_POST['password'])){ $fout.="Er is <i>geen</i> password ingevoerd.<br>"; } if(isset($fout) AND $fout == TRUE){ begintabel("Error"); echo "".$fout.""; eindetabel(); } else { $select = @mysql_query("SELECT * FROM members WHERE nickname='".$_POST['nickname']."' AND password='".md5($_POST['password'])."'"); $aantal = @mysql_num_rows($select); $Show = @mysql_fetch_assoc($select); if($aantal == TRUE){ $hash = rand(9999, 99999); $hash1 = md5($hash); @mysql_query("UPDATE members SET hash='".$hash1."' WHERE id='".$Show['id']."'"); setcookie("userid", $Show['id'], time()+$_POST['tijdingelogd']); setcookie("password", $Show['password'], time()+$_POST['tijdingelogd']); setcookie("hash", $hash1, time()+$_POST['tijdingelogd']); header("location:/test/?page=nieuws.php"); } else { begintabel(" - Inloggen - Error"); echo "Nickname en/of password onjuist!"; eindetabel(); } } } else { begintabel(" - Inloggen"); echo "<form action='inloggen.php?actie=controleren' method='POST'> <table width='100%' border='0' cellpadding='0' cellspacing='0'> <tr><td width='50%' height='24'>Nickname</td> <td width='50%' height='24'><input type='text' name='nickname'></td> </tr><tr> <td width='50%' height='24'>Password</td> <td width='50%' height='24'><input type='password' name='password'> <a href='?page=wwvergeten.php'>password vergeten?</a></td> </tr><tr> <td width='50%' height='24'>Tijd ingelogd</td> <td width='50%' height='24'><select size='1' name='tijdingelogd'> <option value='22118400'>Een jaar</option> <option value='18144000'>Een maand</option> <option value='604800'>Een week</option> <option value='86400'>Een dag</option> <option value='3600'>Een uur</option> <option value='1800'>Half uur</option> </select></td></tr><tr> <td width='50%' height='24'></td> <td width='50%' height='24'><input type='submit' value='Inloggen'></td> </tr> </table>"; eindetabel(); } } ?> |
----------------------------------------------------------
----------------------------------------------------------
uitloggen.php
PHP:
1
2
3
4
5
6
7
8
9
10
| <? ob_start (); include_once("global.inc.php"); setcookie("id"); setcookie("wachtwoord"); setcookie("hash"); header("location:/test/?page=nieuws.php"); ?> |
----------------------------------------------------------
----------------------------------------------------------
global.inc.php
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
| <?php $site['adres'] = "****"; $site['mail'] = "****"; $site['naam'] = "****"; $site['host'] = "****"; $site['user'] = "****"; $site['pass'] ="****"; $site['data'] = "****"; $site['dberror'] = "" . $site['naam'] . " loginsysteem is momenteel offline of is tijdelijk buiten gebruik.<br>Sorry voor het ongemak!"; mysql_connect($site['host'], $site['user'], $site['pass']) or die($site['dberror']); mysql_select_db($site['data']) or die($site['dberror']); if(empty($_COOKIE['userid']) && empty($_COOKIE['password'])){ $ingelogd = 0; } else { $select = "SELECT * FROM members WHERE id = '" . $_COOKIE['userid'] . "' AND password = '" . $_COOKIE['password'] . "' AND hash = '" . $_COOKIE['hash'] . "'"; $sql = mysql_query($select)or die(mysql_error());; $list = mysql_fetch_object($sql); $hash1 = md5($list->hash); if($_COOKIE['password'] == $list->password AND $_COOKIE['userid'] == $list->id AND $_COOKIE['hash'] == $list->hash) { $ingelogd = 1; } else { $ingelogd = 0; } } Function nickname($id,$status,$nickname){ if($status == beheerder) { $user = '<a href=?page=profiel.php&id='.$id.'><font color="#FF0000"><b>'.$nickname.'</a></b></font>'; } elseif($status == 'Super moderator') { $user = '<a href=?page=profiel.php&id='.$id.'><font color="#003399"><b>'.$nickname.'</a></b></font>'; } elseif($status == 'Moderator') { $user = '<a href=?page=profiel.php&id='.$id.'><font color="#0066CC"><b>'.$nickname.'</a></b></font>'; } elseif($status == 'Ere lid') { $user = '<a href=?page=profiel.php&id='.$id.'><font color="#000000"><b>'.$nickname.'</a></b></font>'; } elseif($status == 'Verbannen') { $user = '<a href=?page=profiel.php&id='.$id.'><font color="#000000"><s>'.$nickname.'</a></s></font>'; } elseif($status == 'lid') { $user = '<a href=?page=profiel.php&id='.$id.'><font color="#000000">'.$nickname.'</a>'; } else { $user = '<a href=?page=profiel.php&id='.$id.'><font color="#000000">'.$nickname.'</a>'; } Return $user; } Function eindetabel() { Echo "</td> </tr> </table><br>"; } Function begintabel($title) { Echo '<table style="BORDER-RIGHT: #A3A3A3 1px solid; BORDER-TOP: #A3A3A3 1px solid; BORDER-LEFT: #A3A3A3 1px solid; BORDER-BOTTOM: #A3A3A3 1px solid" cellSpacing="0" cellPadding="0" width="100%" border="0" id="table1"> <tr> <td style="BORDER-BOTTOM: #A3A3A3 1px solid" bgColor="#DFDFDF" height="21"> <font color="#666666"><b>'.$title.'</b></font></td> </tr> <tr> <td style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" bgColor="#DFDFDF">'; } function keygen($tekens = false){ if(!$tekens) $tekens = 10; $sleutel = ""; $array = array ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "v", "x", "y", "z", 1, 2, 3, 4, 5, 6, 7, 8, 9, 0); for ($i = 0; $i < $tekens; $i++) $sleutel .= $array[rand(0, 33)]; return strtoupper($sleutel); } ?> |
----------------------------------------------------------
[ Voor 26% gewijzigd door Fr0zenFlame op 22-04-2005 02:26 ]
i7-6700K | Z170A XPOWER GAMING TITANIUM EDITION | InWin904 | 32GB Corsair Dominator Platinum | nVidia GeForce RTX2080 TI | Iiyama G-Master UWQH 34" | 2x 1TB Samsung SSD 980PRO | 1x 4TB Samsung 860EVO | Arctis 7 | SteelSeries Apex Pro | Logitech G502 Hero