als ik een wachtwoord en gebruikersnaam invul krijg ik de volgende error.
Warning: Cannot add header information - headers already sent by (output started at g:\phpdev\www\login\functions.inc.php:159) in g:\phpdev\www\login\functions.inc.php on line 13
Warning: Cannot add header information - headers already sent by (output started at g:\phpdev\www\login\functions.inc.php:159) in g:\phpdev\www\login\functions.inc.php on line 130
Wie weet wat hier mis mee is.
--------------------------------------------------------------------------------
Warning: Cannot add header information - headers already sent by (output started at g:\phpdev\www\login\functions.inc.php:159) in g:\phpdev\www\login\functions.inc.php on line 13
Warning: Cannot add header information - headers already sent by (output started at g:\phpdev\www\login\functions.inc.php:159) in g:\phpdev\www\login\functions.inc.php on line 130
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
| <?php require_once("../php/sql.php"); verbind(); /* filename: functions.inc.php */ // This function sets a cookie function set_cookie($name="",$value="",$time="") { if (empty($time)) { $time = time()+(60*60*24*365*10); } if (!empty($name) && !empty($value)) { setcookie($name,$value,$time,"/~trouby/","members.webdeveloping.nl",0); } else { print "An error occur: Failed to place the cookie"; } } // Removes a cookie. Only needs the name of the cookie function log_out($name="") { set_cookie($name,"x",time()-(60*60*24*365*11)); } // This function will test the cookie, when it is succesfull it will print the login screen. // when it failes it will print information about how the user could enable cookies. function test_cookie($nickname="",$password="",$cookie="login") { list($name,$pass) = explode(':',$_COOKIE[$cookie]); if ($nickname==$name && $password==$pass) { header("Location: member_login.php"); } else { echo "Login was correct, but the cookie wasn't set succesfull. Please enable your cookies."; } } // Checks a correct login. It will return TRUE when the cookie content is the same with the // information in the database function check_login($cookie="login",$db_rij="login") { list($name,$pass) = explode(':',$_COOKIE[$cookie]); if (!empty($name) && !empty($pass)) { $query = mysql_query("SELECT password, nickname FROM ".$db_rij." WHERE nickname='$name'"); $rij = mysql_fetch_object($query); $password = md5($rij->password); if ($password==$pass && $rij->nickname==$name) return TRUE; else { log_out($cookie); die("Please login again"); } } else return FALSE; } // Checks a correct login. It will return TRUE when the cookie content is the same with the // information in the database function check_auth($cookie="login",$db_rij="login") { list($name,$pass) = explode(":",$_COOKIE[$cookie]); if (!empty($name) && !empty($pass)) { $query = mysql_query("SELECT password, nickname, status FROM ".$db_rij." WHERE nickname='$name'"); $rij = mysql_fetch_object($query); $password = md5($rij->password); if ($password==$pass && $rij->nickname==$name && $rij->status=="admin") return "admin"; elseif ($password==$pass && $rij->nickname==$name && $rij->status=="moderator") return "moderator"; else { print "You don't got the rights to visit this page"; } } else { print "You don't got the rights to visit this page"; } } function check_admin($cookie="login",$db_rij="login") { list($name,$pass) = explode(":",$_COOKIE[$cookie]); if (!empty($name) && !empty($pass)) { $query = mysql_query("SELECT password, nickname, status FROM ".$db_rij." WHERE nickname='$name'"); $rij = mysql_fetch_object($query); $password = md5($rij->password); if ($password==$pass && $rij->nickname==$name && $rij->status=="admin") return TRUE; elseif ($password==$pass && $rij->nickname==$name && $rij->status=="moderator") return FALSE; else return FALSE; } else return FALSE; } function check_mod($cookie="login",$db_rij="login") { list($name,$pass) = explode(":",$_COOKIE[$cookie]); if (!empty($name) && !empty($pass)) { $query = mysql_query("SELECT password, nickname, status FROM ".$db_rij." WHERE nickname='$name'"); $rij = mysql_fetch_object($query); $password = md5($rij->password); if ($password==$pass && $rij->nickname==$name && $rij->status=="admin") return TRUE; elseif ($password==$pass && $rij->nickname==$name && $rij->status=="moderator") return TRUE; else return FALSE; } else return FALSE; } // This function compares the form login results with the results in the database // when it failes it will return an error message and gives the user another change to login. // When is result is true, it will load the test function function set_login($nickname="",$password="",$db_rij="login") { if (empty($nickname) || empty($password)) return FALSE; $query = mysql_query("SELECT id FROM ".$db_rij." WHERE nickname='".$nickname."' AND password='".$password."'"); $results = mysql_num_rows($query); if ($results == "1") { $pass = md5($password); $value = $nickname.":".$pass; set_cookie("quake",$value); header("Location: member_login.php?action=test&n=".$nickname."&p=".$pass); } else { print "Incorrect login"; print "<meta http-equiv=refresh content=\"1; url=member_login.php\">"; } } // This function sends the password to the email which belongs by the password. // The input is the nickname from the password. It will return TRUE when the // email has been send. function send_pass($nickname="",$db_rij="login") { if (empty($nickname)) return FALSE; $query = mysql_query("SELECT password, nickname, email FROM ".$db_rij." WHERE nickname='$nickname'"); $row = mysql_fetch_array($query); if (mysql_num_rows($query) > 0) { $headers = "From: www@nqeu.tk\r\nReply-To: www@nqeu.tk\r\n"; $messagebody = "Hi ".$row['nickname'].", \n\nThis message has been send to you by the NQEU.tk Password Recovery Tool.\n\nYour password is: ".$row['password']." \n\nIf for some reason you received this message by mistake, you may just delete it. Otherwise it maybe wise to keep it at a safe place and use it if you forgot your password again.\n\nThe NQEU.tk Team\nhttp://www.nqeu.tk"; $send = @mail($row['email'], "NQEU.tk password recovery", $messagebody, $headers); $x = $send ? "There has been send an email message, containing your password.":"An error occur: Could not send your password."; print $x; } else return FALSE; } verbreek(); ?> -------------------- <?php /* filename : member_login.php */ require "functions.inc.php"; verbind(); if ($_POST["requestpw"] == "1") send_pass($_POST["nickname"]); elseif ($_GET["action"] == "logout") { log_out("quake"); header("Location: member_login.php"); } elseif ($_GET["action"] == "test") test_cookie($_GET["n"],$_GET["p"]); else { if (check_login()) { list($name,$pass) = explode(':',$_COOKIE["quake"]); print $name." ,you are logged in.<br /><a href=\"member_login.php?action=logout\">log out</a>"; } else { if ($_POST["submit"] == "Login") { if (empty($_POST["nickname"]) || empty($_POST["password"])) { print "Incorrect login"; print "<meta http-equiv=\"refresh\" content=\"1; url=member_login.php\">"; } else set_login($_POST["nickname"],$_POST["password"]); } else { ?> Please fill in your Nickname and Password. Username and password are CaSE-SenSiTivE. <form action="member_login.php" method="post"> Nickname: <select name="nickname" id="nickname" class="form"> <option selected="selected" value=" ">Your Nickname:</option> <?php // Een rij met gebruikersnamen maken, zodat de gebruiker sneller kan inloggen. Vaak // zijn ze vergeten of hun naam nou met een kleine of grote hoofdletter geschreven // werd. $query = mysql_query("SELECT nickname FROM login ORDER BY nickname ASC"); while ($rij = mysql_fetch_object($query)) { print "<option value=\"".$rij->nickname."\">".$rij->nickname."</option>\n"; } ?> </select> <br /> Password: <input type="password" name="password" id="password" size="15" maxlength="15" class="form" /> <br /> <input type="checkbox" name="requestpw" id="requestpw" value="1" /> Sent password to my e-mail <br /> <br /> <input type="submit" value="Login" class="button" name="submit" /> </form> <?php } } } ?> |
Wie weet wat hier mis mee is.
--------------------------------------------------------------------------------
[ Voor 16% gewijzigd door Verwijderd op 17-07-2003 14:19 ]