Admin Page Probleempje
maar wij willen met 2 man de website onderhouden.
Nu willen we deze dat we deze dus in de config invoegen.
Als ik 1 admin naam en password erin heb dan doet hij het maar bij de 2e niet meer.
Code (php)
1
if($_POST["username"] == "$admin_username","$admin_username1" && "$admin_password","$admin_password1" == $_POST["password"]){
Weet iemand wat ik fout doe
Is het niet handiger om het in een database te zetten ?...
Code (php)
1
2
3
2
3
<?php
if(($_POST['username'] == $admin_username || $_POST['username'] == $admin_username1) && ($_POST['password'] == ...))
?>
if(($_POST['username'] == $admin_username || $_POST['username'] == $admin_username1) && ($_POST['password'] == ...))
?>
Maar goed, zoals je ziet wordt dat nogal omslachtig als je meerdere gebruikers krijgt. Je kunt beter een array gebruiken in dit geval:
Hier de complete Admin Page:
Code (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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
<?
session_start();
include("config.inc.php");
?>
<html>
<head>
<title>Admin</title>
<link href="http://dwork.nl/nieuws/admin/admin-style.css" type="text/css" rel="stylesheet" media="screen" />
<link href="http://dwork.nl/nieuws/admin/admin-color.css" type="text/css" rel="stylesheet" media="screen" />
</head>
<body>
<div id="wrapper"></div>
<div id="content">
<h1><acronym title="XML scripting">Stabilo Games</acronym>: admin</h1>
<?
if(!isset($_SESSION["admin"])){
if(isset($_POST["username"]) && isset($_POST["password"])){
if($_POST["username"] == "$admin_username","$admin_username1" && "$admin_password","$admin_password1" == $_POST["password"]){
$_SESSION["admin"] = true;
}else{
?>
<p style="color: red">Foute login gegevens</p>
<form method="post" action="admin.php">
<table>
<tr><td>Gebruikersnaam</td><td><input type="text" name="username" /></td></tr>
<tr><td>Wachtwoord</td><td><input type="password" name="password" /></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Inloggen" /></td></tr>
</table>
</form>
<?
die();
}
}else{
?>
<form method="post" action="admin.php">
<table>
<tr><td>Gebruikersnaam</td><td><input type="text" name="username" /></td></tr>
<tr><td>Wachtwoord</td><td><input type="password" name="password" /></td></tr>
<tr><td colspan="2"><input class="button" type="submit" /></td></tr>
</table>
</form>
<?
die();
}
}
?>
<? //Categorie toevoegen
if(isset($_POST["cat_name"])){
$name=mysql_real_escape_string($_POST["cat_name"]);
$query="INSERT INTO category (id, name) VALUES
('','$name');";
mysql_query($query);
echo "<p style=\"color: green;\">De category is succesvol toegevoegd</p>";
}
?>
<? //Categorie verwijderen
if(isset($_GET["delcat"])){
$id=mysql_real_escape_string($_GET["delcat"]);
$query="DELETE FROM category WHERE id='$id';";
mysql_query($query);
echo "<p style=\"color: green;\">De category is succesvol verwijderd</p>";
}
?>
<? //Linkpartner toevoegen
if(isset($_POST["link_name"]) && isset($_POST["link_url"])){
$name=mysql_real_escape_string($_POST["link_name"]);
$url=mysql_real_escape_string($_POST["link_url"]);
$query="INSERT INTO linkpartner (id, name, url) VALUES
('','$name', '$url');";
mysql_query($query);
echo "<p style=\"color: green;\">De linkpartner is succesvol toegevoegd</p>";
}
?>
<? //Linkpartner verwijderen
if(isset($_GET["dellink"])){
$id=mysql_real_escape_string($_GET["dellink"]);
$query="DELETE FROM linkpartner WHERE id='$id';";
mysql_query($query);
echo "<p style=\"color: green;\">De linkpartner is succesvol verwijderd</p>";
}
?>
<? //Banner toevoegen
if(isset($_POST["ads_HTML"]) && isset($_GET["zone"])){
$HTML=$_POST["ads_HTML"];
$zone=$_GET["zone"];
$query="INSERT INTO ads (id, zone, html) VALUES
('','$zone', '$HTML');";
mysql_query($query);
echo "<p style=\"color: green;\">De banner is succesvol toegevoegd</p>";
}
?>
<? //Banner verwijderen
if(isset($_GET["delads"])){
$id=mysql_real_escape_string($_GET["delads"]);
$query="DELETE FROM ads WHERE id='$id';";
mysql_query($query);
echo "<p style=\"color: green;\">De banner is succesvol verwijderd</p>";
}
?>
<? //Spel toevoegen
if(isset($_POST["name"]) && isset($_POST["url"]) && isset($_POST["screenshot"]) && isset($_POST["category"])
&& isset($_POST["width"]) && isset($_POST["height"])){
$name=mysql_real_escape_string($_POST["name"]);
$url=mysql_real_escape_string($_POST["url"]);
$screenshot=mysql_real_escape_string($_POST["screenshot"]);
$category=mysql_real_escape_string($_POST["category"]);
$width=mysql_real_escape_string($_POST["width"]);
$height=mysql_real_escape_string($_POST["height"]);
$query="INSERT INTO game (id, name, url, screenshot, category, width, height, date) VALUES
('','$name','$url','$screenshot','$category','$width','$height', '" . time() . "');";
mysql_query($query);
echo "<p style=\"color: green;\">Het spel is succesvol toegevoegd</p>";
}
?>
<? //Spel verwijderen
if(isset($_GET["delgame"])){
$id=mysql_real_escape_string($_GET["delgame"]);
$query="DELETE FROM game WHERE id='$id';";
mysql_query($query);
echo "<p style=\"color: green;\">Het spel is succesvol verwijderd</p>";
$query="DELETE FROM notice WHERE game='$id';";
mysql_query($query);
}
?>
<? //Spel-werkt-niet-melding verwijderen
if(isset($_GET["delnotice"])){
$id=mysql_real_escape_string($_GET["delnotice"]);
$query="DELETE FROM notice WHERE game='$id';";
mysql_query($query);
echo "<p style=\"color: green;\">De melding is succesvol verwijderd</p>";
}
?>
<? //Spel aanpassen
if(isset($_POST["edit_game_name"])){
$name=mysql_real_escape_string($_POST["edit_game_name"]);
$query="SELECT * FROM game WHERE name='$name';";
$result=mysql_query($query);
if(mysql_num_rows($result) > 0){
$game=mysql_fetch_object($result);
if(isset($_POST["ename"]) && isset($_POST["eurl"]) && isset($_POST["escreenshot"]) && isset($_POST["ecategory"])
&& isset($_POST["ewidth"]) && isset($_POST["eheight"])){
$name=mysql_real_escape_string($_POST["ename"]);
$url=mysql_real_escape_string($_POST["eurl"]);
$screenshot=mysql_real_escape_string($_POST["escreenshot"]);
$category=mysql_real_escape_string($_POST["ecategory"]);
$width=mysql_real_escape_string($_POST["ewidth"]);
$height=mysql_real_escape_string($_POST["eheight"]);
$query="UPDATE game SET name='$name', url='$url', screenshot='$screenshot',
category='$category', width='$width', height='$height' WHERE name='" . $game->name . "';";
mysql_query($query);
echo "<p style=\"color: green;\">Het spel is succesvol aangepast</p>";
}else{
?>
<form method="post" action="admin.php">
<input type="hidden" name="edit_game_name" value="<? echo $game->name; ?>" />
<table>
<tr><td>Naam: </td><td><input name="ename" type="text" value="<? echo $game->name; ?>" /></td></tr>
<tr><td>URL: </td><td><input name="eurl" type="text" value="<? echo $game->url; ?>" /></td></tr>
<tr><td>Screenshot: </td><td><input name="escreenshot" type="text" value="<? echo $game->screenshot; ?>" /></td></tr>
<tr><td>Categorie id: </td><td><input name="ecategory" type="text" value="<? echo $game->category; ?>" /></td></tr>
<tr><td>Width: </td><td><input name="ewidth" type="text" value="<? echo $game->width; ?>" /></td></tr>
<tr><td>Height: </td><td><input name="eheight" type="text" value="<? echo $game->height; ?>" /></td></tr>
<tr><td colspan="2"><input type="submit" value="Verzenden" /></td></tr>
</table>
</form>
<input class="button" type="button" value="Verwijder dit spel" onclick="if(confirm('Weet u zeker dat u dit spel wilt verwijderen?')) window.location='admin.php?delgame=<? echo $game->id; ?>';" />
<?
die();
}
}else{
echo "<p style=\"color: red;\">De spelnaam die u opgaf bestaat niet</p>";
}
}
?>
<b>Pas een spel aan</b>
<p>
<form method="post" action="admin.php">
<table>
<tr><td>Naam: </td><td><input name="edit_game_name" type="text" /></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Voeg een spel toe</b>
<p>
<form method="post" action="admin.php">
<table>
<tr><td>Naam: </td><td><input name="name" type="text" /></td></tr>
<tr><td>URL: </td><td><input name="url" type="text" /></td></tr>
<tr><td>Screenshot: </td><td><input name="screenshot" type="text" /></td></tr>
<tr><td>Categorie id: </td><td><input name="category" type="text" /></td></tr>
<tr><td>Width: </td><td><input name="width" type="text" /></td></tr>
<tr><td>Height: </td><td><input name="height" type="text" /></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Categorie overzicht</b>
<ul>
<?
$query="SELECT * FROM category WHERE 1 ORDER BY id ASC;";
$result=mysql_query($query);
while($category = mysql_fetch_object($result)):
?>
<li><span><? echo $category->id; ?> - <? echo $category->name; ?> - <a href="#" onclick="if(confirm('Weet u zeker dat u de categorie wilt verwijderen?')) window.location='admin.php?delcat=<? echo $category->id; ?>';">Verwijderen</a></span></li>
<?
endwhile;
?>
</ul>
<b>Voeg een categorie toe</b>
<p>
<form method="post" action="admin.php">
<table>
<tr><td>Naam: </td><td><input name="cat_name" type="text" /></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Linkpartners</b>
<ul>
<?
$query="SELECT * FROM linkpartner WHERE 1 ORDER BY id ASC;";
$result=mysql_query($query);
while($linkpartner = mysql_fetch_object($result)):
?>
<li><span><? echo $linkpartner->name; ?> - <a href="#" onclick="if(confirm('Weet u zeker dat u de linkpartner wilt verwijderen?')) window.location='admin.php?dellink=<? echo $linkpartner->id; ?>';">Verwijderen</a></span></li>
<?
endwhile;
?>
</ul>
<b>Voeg een linkpartner toe</b>
<p>
<form method="post" action="admin.php">
<table>
<tr><td>Naam: </td><td><input name="link_name" type="text" /></td></tr>
<tr><td>URL: </td><td><input name="link_url" type="text" /></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Banners - Indexbanner (120x60)</b>
<ul>
<?
$query="SELECT * FROM ads WHERE zone=1 ORDER BY id ASC;";
$result=mysql_query($query);
while($ads = mysql_fetch_object($result)):
?>
<li><span><? echo htmlentities($ads->HTML); ?> - <a href="#" onclick="if(confirm('Weet u zeker dat u de banner wilt verwijderen?')) window.location='admin.php?delads=<? echo $ads->id; ?>';">Verwijderen</a></span></li>
<?
endwhile;
?>
</ul>
<b>Voeg een banner toe - Indexbanner (120x60)</b>
<p>
<form method="post" action="admin.php?zone=1">
<table>
<tr><td>HTML: </td><td><textarea name="ads_HTML"></textarea></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Banners - Spellen pagina - Skycraper</b>
<ul>
<?
$query="SELECT * FROM ads WHERE zone=2 ORDER BY id ASC;";
$result=mysql_query($query);
while($ads = mysql_fetch_object($result)):
?>
<li><span><? echo htmlentities($ads->HTML); ?> - <a href="#" onclick="if(confirm('Weet u zeker dat u de banner wilt verwijderen?')) window.location='admin.php?delads=<? echo $ads->id; ?>';">Verwijderen</a></span></li>
<?
endwhile;
?>
</ul>
<b>Voeg een banner toe - Spellen pagina - Skycraper</b>
<p>
<form method="post" action="admin.php?zone=2">
<table>
<tr><td>HTML: </td><td><textarea name="ads_HTML"></textarea></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Banners - Spellen pagina - tekstlink</b>
<ul>
<?
$query="SELECT * FROM ads WHERE zone=3 ORDER BY id ASC;";
$result=mysql_query($query);
while($ads = mysql_fetch_object($result)):
?>
<li><span><? echo htmlentities($ads->HTML); ?> - <a href="#" onclick="if(confirm('Weet u zeker dat u de banner wilt verwijderen?')) window.location='admin.php?delads=<? echo $ads->id; ?>';">Verwijderen</a></span></li>
<?
endwhile;
?>
</ul>
<b>Voeg een banner toe - Spellen pagina - tekstlink</b>
<p>
<form method="post" action="admin.php?zone=3">
<table>
<tr><td>HTML: </td><td><textarea name="ads_HTML"></textarea></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Niet werkende spellen - meldingen</b>
<ul>
<?
$query="SELECT * FROM notice WHERE 1;";
$result=mysql_query($query);
while($notice = mysql_fetch_object($result)){
$query="SELECT * FROM game WHERE id='" . $notice->game . "';";
$res=mysql_query($query);
$game=mysql_fetch_object($res);
if(!isset($notices[$game->name])){
$notices[$game->name]=$game;
$notices[$game->name]->count=0;
}
$notices[$game->name]->count++;
}
if(isset($notices)){
foreach($notices as $notice){
?>
<li><span><a href="spel/<? echo str_replace(" ","+",$notice->name); ?>"><? echo $notice->name . " (" . $notice->count . "x)"; ?></a> - <a href="admin.php?delnotice=<? echo $notice->id; ?>">verwijder melding</a> - <a href="#" onclick="if(confirm('Weet u zeker dat u het hele spel wilt verwijderen?')) window.location='admin.php?delgame=<? echo $notice->id; ?>';">verwijder het spel</a></span></li>
<?
}
}
?>
</ul>
</div>
</body>
</html>
session_start();
include("config.inc.php");
?>
<html>
<head>
<title>Admin</title>
<link href="http://dwork.nl/nieuws/admin/admin-style.css" type="text/css" rel="stylesheet" media="screen" />
<link href="http://dwork.nl/nieuws/admin/admin-color.css" type="text/css" rel="stylesheet" media="screen" />
</head>
<body>
<div id="wrapper"></div>
<div id="content">
<h1><acronym title="XML scripting">Stabilo Games</acronym>: admin</h1>
<?
if(!isset($_SESSION["admin"])){
if(isset($_POST["username"]) && isset($_POST["password"])){
if($_POST["username"] == "$admin_username","$admin_username1" && "$admin_password","$admin_password1" == $_POST["password"]){
$_SESSION["admin"] = true;
}else{
?>
<p style="color: red">Foute login gegevens</p>
<form method="post" action="admin.php">
<table>
<tr><td>Gebruikersnaam</td><td><input type="text" name="username" /></td></tr>
<tr><td>Wachtwoord</td><td><input type="password" name="password" /></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Inloggen" /></td></tr>
</table>
</form>
<?
die();
}
}else{
?>
<form method="post" action="admin.php">
<table>
<tr><td>Gebruikersnaam</td><td><input type="text" name="username" /></td></tr>
<tr><td>Wachtwoord</td><td><input type="password" name="password" /></td></tr>
<tr><td colspan="2"><input class="button" type="submit" /></td></tr>
</table>
</form>
<?
die();
}
}
?>
<? //Categorie toevoegen
if(isset($_POST["cat_name"])){
$name=mysql_real_escape_string($_POST["cat_name"]);
$query="INSERT INTO category (id, name) VALUES
('','$name');";
mysql_query($query);
echo "<p style=\"color: green;\">De category is succesvol toegevoegd</p>";
}
?>
<? //Categorie verwijderen
if(isset($_GET["delcat"])){
$id=mysql_real_escape_string($_GET["delcat"]);
$query="DELETE FROM category WHERE id='$id';";
mysql_query($query);
echo "<p style=\"color: green;\">De category is succesvol verwijderd</p>";
}
?>
<? //Linkpartner toevoegen
if(isset($_POST["link_name"]) && isset($_POST["link_url"])){
$name=mysql_real_escape_string($_POST["link_name"]);
$url=mysql_real_escape_string($_POST["link_url"]);
$query="INSERT INTO linkpartner (id, name, url) VALUES
('','$name', '$url');";
mysql_query($query);
echo "<p style=\"color: green;\">De linkpartner is succesvol toegevoegd</p>";
}
?>
<? //Linkpartner verwijderen
if(isset($_GET["dellink"])){
$id=mysql_real_escape_string($_GET["dellink"]);
$query="DELETE FROM linkpartner WHERE id='$id';";
mysql_query($query);
echo "<p style=\"color: green;\">De linkpartner is succesvol verwijderd</p>";
}
?>
<? //Banner toevoegen
if(isset($_POST["ads_HTML"]) && isset($_GET["zone"])){
$HTML=$_POST["ads_HTML"];
$zone=$_GET["zone"];
$query="INSERT INTO ads (id, zone, html) VALUES
('','$zone', '$HTML');";
mysql_query($query);
echo "<p style=\"color: green;\">De banner is succesvol toegevoegd</p>";
}
?>
<? //Banner verwijderen
if(isset($_GET["delads"])){
$id=mysql_real_escape_string($_GET["delads"]);
$query="DELETE FROM ads WHERE id='$id';";
mysql_query($query);
echo "<p style=\"color: green;\">De banner is succesvol verwijderd</p>";
}
?>
<? //Spel toevoegen
if(isset($_POST["name"]) && isset($_POST["url"]) && isset($_POST["screenshot"]) && isset($_POST["category"])
&& isset($_POST["width"]) && isset($_POST["height"])){
$name=mysql_real_escape_string($_POST["name"]);
$url=mysql_real_escape_string($_POST["url"]);
$screenshot=mysql_real_escape_string($_POST["screenshot"]);
$category=mysql_real_escape_string($_POST["category"]);
$width=mysql_real_escape_string($_POST["width"]);
$height=mysql_real_escape_string($_POST["height"]);
$query="INSERT INTO game (id, name, url, screenshot, category, width, height, date) VALUES
('','$name','$url','$screenshot','$category','$width','$height', '" . time() . "');";
mysql_query($query);
echo "<p style=\"color: green;\">Het spel is succesvol toegevoegd</p>";
}
?>
<? //Spel verwijderen
if(isset($_GET["delgame"])){
$id=mysql_real_escape_string($_GET["delgame"]);
$query="DELETE FROM game WHERE id='$id';";
mysql_query($query);
echo "<p style=\"color: green;\">Het spel is succesvol verwijderd</p>";
$query="DELETE FROM notice WHERE game='$id';";
mysql_query($query);
}
?>
<? //Spel-werkt-niet-melding verwijderen
if(isset($_GET["delnotice"])){
$id=mysql_real_escape_string($_GET["delnotice"]);
$query="DELETE FROM notice WHERE game='$id';";
mysql_query($query);
echo "<p style=\"color: green;\">De melding is succesvol verwijderd</p>";
}
?>
<? //Spel aanpassen
if(isset($_POST["edit_game_name"])){
$name=mysql_real_escape_string($_POST["edit_game_name"]);
$query="SELECT * FROM game WHERE name='$name';";
$result=mysql_query($query);
if(mysql_num_rows($result) > 0){
$game=mysql_fetch_object($result);
if(isset($_POST["ename"]) && isset($_POST["eurl"]) && isset($_POST["escreenshot"]) && isset($_POST["ecategory"])
&& isset($_POST["ewidth"]) && isset($_POST["eheight"])){
$name=mysql_real_escape_string($_POST["ename"]);
$url=mysql_real_escape_string($_POST["eurl"]);
$screenshot=mysql_real_escape_string($_POST["escreenshot"]);
$category=mysql_real_escape_string($_POST["ecategory"]);
$width=mysql_real_escape_string($_POST["ewidth"]);
$height=mysql_real_escape_string($_POST["eheight"]);
$query="UPDATE game SET name='$name', url='$url', screenshot='$screenshot',
category='$category', width='$width', height='$height' WHERE name='" . $game->name . "';";
mysql_query($query);
echo "<p style=\"color: green;\">Het spel is succesvol aangepast</p>";
}else{
?>
<form method="post" action="admin.php">
<input type="hidden" name="edit_game_name" value="<? echo $game->name; ?>" />
<table>
<tr><td>Naam: </td><td><input name="ename" type="text" value="<? echo $game->name; ?>" /></td></tr>
<tr><td>URL: </td><td><input name="eurl" type="text" value="<? echo $game->url; ?>" /></td></tr>
<tr><td>Screenshot: </td><td><input name="escreenshot" type="text" value="<? echo $game->screenshot; ?>" /></td></tr>
<tr><td>Categorie id: </td><td><input name="ecategory" type="text" value="<? echo $game->category; ?>" /></td></tr>
<tr><td>Width: </td><td><input name="ewidth" type="text" value="<? echo $game->width; ?>" /></td></tr>
<tr><td>Height: </td><td><input name="eheight" type="text" value="<? echo $game->height; ?>" /></td></tr>
<tr><td colspan="2"><input type="submit" value="Verzenden" /></td></tr>
</table>
</form>
<input class="button" type="button" value="Verwijder dit spel" onclick="if(confirm('Weet u zeker dat u dit spel wilt verwijderen?')) window.location='admin.php?delgame=<? echo $game->id; ?>';" />
<?
die();
}
}else{
echo "<p style=\"color: red;\">De spelnaam die u opgaf bestaat niet</p>";
}
}
?>
<b>Pas een spel aan</b>
<p>
<form method="post" action="admin.php">
<table>
<tr><td>Naam: </td><td><input name="edit_game_name" type="text" /></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Voeg een spel toe</b>
<p>
<form method="post" action="admin.php">
<table>
<tr><td>Naam: </td><td><input name="name" type="text" /></td></tr>
<tr><td>URL: </td><td><input name="url" type="text" /></td></tr>
<tr><td>Screenshot: </td><td><input name="screenshot" type="text" /></td></tr>
<tr><td>Categorie id: </td><td><input name="category" type="text" /></td></tr>
<tr><td>Width: </td><td><input name="width" type="text" /></td></tr>
<tr><td>Height: </td><td><input name="height" type="text" /></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Categorie overzicht</b>
<ul>
<?
$query="SELECT * FROM category WHERE 1 ORDER BY id ASC;";
$result=mysql_query($query);
while($category = mysql_fetch_object($result)):
?>
<li><span><? echo $category->id; ?> - <? echo $category->name; ?> - <a href="#" onclick="if(confirm('Weet u zeker dat u de categorie wilt verwijderen?')) window.location='admin.php?delcat=<? echo $category->id; ?>';">Verwijderen</a></span></li>
<?
endwhile;
?>
</ul>
<b>Voeg een categorie toe</b>
<p>
<form method="post" action="admin.php">
<table>
<tr><td>Naam: </td><td><input name="cat_name" type="text" /></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Linkpartners</b>
<ul>
<?
$query="SELECT * FROM linkpartner WHERE 1 ORDER BY id ASC;";
$result=mysql_query($query);
while($linkpartner = mysql_fetch_object($result)):
?>
<li><span><? echo $linkpartner->name; ?> - <a href="#" onclick="if(confirm('Weet u zeker dat u de linkpartner wilt verwijderen?')) window.location='admin.php?dellink=<? echo $linkpartner->id; ?>';">Verwijderen</a></span></li>
<?
endwhile;
?>
</ul>
<b>Voeg een linkpartner toe</b>
<p>
<form method="post" action="admin.php">
<table>
<tr><td>Naam: </td><td><input name="link_name" type="text" /></td></tr>
<tr><td>URL: </td><td><input name="link_url" type="text" /></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Banners - Indexbanner (120x60)</b>
<ul>
<?
$query="SELECT * FROM ads WHERE zone=1 ORDER BY id ASC;";
$result=mysql_query($query);
while($ads = mysql_fetch_object($result)):
?>
<li><span><? echo htmlentities($ads->HTML); ?> - <a href="#" onclick="if(confirm('Weet u zeker dat u de banner wilt verwijderen?')) window.location='admin.php?delads=<? echo $ads->id; ?>';">Verwijderen</a></span></li>
<?
endwhile;
?>
</ul>
<b>Voeg een banner toe - Indexbanner (120x60)</b>
<p>
<form method="post" action="admin.php?zone=1">
<table>
<tr><td>HTML: </td><td><textarea name="ads_HTML"></textarea></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Banners - Spellen pagina - Skycraper</b>
<ul>
<?
$query="SELECT * FROM ads WHERE zone=2 ORDER BY id ASC;";
$result=mysql_query($query);
while($ads = mysql_fetch_object($result)):
?>
<li><span><? echo htmlentities($ads->HTML); ?> - <a href="#" onclick="if(confirm('Weet u zeker dat u de banner wilt verwijderen?')) window.location='admin.php?delads=<? echo $ads->id; ?>';">Verwijderen</a></span></li>
<?
endwhile;
?>
</ul>
<b>Voeg een banner toe - Spellen pagina - Skycraper</b>
<p>
<form method="post" action="admin.php?zone=2">
<table>
<tr><td>HTML: </td><td><textarea name="ads_HTML"></textarea></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Banners - Spellen pagina - tekstlink</b>
<ul>
<?
$query="SELECT * FROM ads WHERE zone=3 ORDER BY id ASC;";
$result=mysql_query($query);
while($ads = mysql_fetch_object($result)):
?>
<li><span><? echo htmlentities($ads->HTML); ?> - <a href="#" onclick="if(confirm('Weet u zeker dat u de banner wilt verwijderen?')) window.location='admin.php?delads=<? echo $ads->id; ?>';">Verwijderen</a></span></li>
<?
endwhile;
?>
</ul>
<b>Voeg een banner toe - Spellen pagina - tekstlink</b>
<p>
<form method="post" action="admin.php?zone=3">
<table>
<tr><td>HTML: </td><td><textarea name="ads_HTML"></textarea></td></tr>
<tr><td colspan="2"><input class="button" type="submit" value="Verzenden" /></td></tr>
</table>
</form>
</p>
<b>Niet werkende spellen - meldingen</b>
<ul>
<?
$query="SELECT * FROM notice WHERE 1;";
$result=mysql_query($query);
while($notice = mysql_fetch_object($result)){
$query="SELECT * FROM game WHERE id='" . $notice->game . "';";
$res=mysql_query($query);
$game=mysql_fetch_object($res);
if(!isset($notices[$game->name])){
$notices[$game->name]=$game;
$notices[$game->name]->count=0;
}
$notices[$game->name]->count++;
}
if(isset($notices)){
foreach($notices as $notice){
?>
<li><span><a href="spel/<? echo str_replace(" ","+",$notice->name); ?>"><? echo $notice->name . " (" . $notice->count . "x)"; ?></a> - <a href="admin.php?delnotice=<? echo $notice->id; ?>">verwijder melding</a> - <a href="#" onclick="if(confirm('Weet u zeker dat u het hele spel wilt verwijderen?')) window.location='admin.php?delgame=<? echo $notice->id; ?>';">verwijder het spel</a></span></li>
<?
}
}
?>
</ul>
</div>
</body>
</html>
Verder is het misschien handig om eens een beginnershandleiding zoals deze door te lezen, dan wordt e.e.a. je wellicht iets duidelijker.
$admin_username en $admin_password die staan ik het config.inc.php bestand deze doet het gewoon het gaat er mij gewoon om dat ik 2 beheerders erin kan zetten met 2 aparte gebruikersnamen en wachtwoorden.
Als je regel 2 uit mijn voorbeeld nu in je config.inc.php opneemt en vervolgens regel 24 uit jouw script vervangt door regel 4 uit mijn voorbeeld, ben je al klaar.
Uiteraard moet je nog wel even de variabelen aanpassen zodat ze in je eigen script werken...
alvast bedankt.
De tweede stap die ik aangaf toegepast op jouw script:
Code (php)
En nu zul je in je config.inc.php de regels waar je de gebruikersnamen echt wachtwoorden definieert moeten vervangen door regel 2 uit mijn voorbeeld en daarin de gebruikersnamen en wachtwoorden definieren.