Bonjour à tous,

j'ai un petit souci d'index et de variables dans un fichier, je ne comprend pas pourquoi ce message d'erreur, j'ai bien trouvé des moyens pour le bypasser mais je souhaiterai comprendre.
si vous voulez bien m'éclairer, j'en serai ravi..
Nom : Capture.PNG
Affichages : 140
Taille : 17,7 Ko
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
	<meta charset="utf-8" />
	<title>Admin Dashboard</title>
	<meta content="width=device-width, initial-scale=1.0" name="viewport" />
	<meta content="" name="description" />
	<meta content="" name="author" />
	<!-- BEGIN GLOBAL MANDATORY STYLES -->        
	<link href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
	<link href="assets/plugins/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css"/>
	<link href="assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
	<link href="assets/css/style-metro.css" rel="stylesheet" type="text/css"/>
	<link href="assets/css/style.css" rel="stylesheet" type="text/css"/>
	<link href="assets/css/style-responsive.css" rel="stylesheet" type="text/css"/>
	<link href="assets/css/themes/default.css" rel="stylesheet" type="text/css" id="style_color"/>
	<link href="assets/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
	<!-- END GLOBAL MANDATORY STYLES -->
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">
	<!-- BEGIN HEADER -->   
	<div class="header navbar navbar-inverse navbar-fixed-top">
		<!-- BEGIN TOP NAVIGATION BAR -->
		<div class="navbar-inner">
			<div class="container-fluid">
 
				<!-- BEGIN RESPONSIVE MENU TOGGLER -->
				<a href="javascript:;" class="btn-navbar collapsed" data-toggle="collapse" data-target=".nav-collapse">
				<img src="assets/img/menu-toggler.png" alt="" />
				</a>          
				<!-- END RESPONSIVE MENU TOGGLER -->            
 
	</div>
	<!-- END HEADER -->
	<!-- BEGIN CONTAINER -->
	<div class="page-container">
		<!-- BEGIN SIDEBAR -->
		<div class="page-sidebar nav-collapse collapse">
			<!-- BEGIN SIDEBAR MENU -->        
			<ul class="page-sidebar-menu">				
				<li class="start active">
					<a href="dash.php">
					<i class="icon-home"></i> 
					<span class="title">Tableau de bord</span>
					<span class="selected"></span>
					</a>
				</li>
 
				<!--<li class="start"><a href="index.html">	<i class="icon-chevron-right"></i> 
					<span class="title">Test</span>
					</a>
				</li>-->
 
				<?php
				$tables = file_get_contents('conf/tables.txt');
				$split = explode("/", $tables);
 
				foreach ($split as $item) {
					if($item != ""){
						echo '<li class="start"><a href="dash.php?n='.$item.'"><i class="icon-chevron-right"></i><span class="title">'.$item.'</span></a></li>';
					}
				}
 
				?>
 
			</ul>
			<!-- END SIDEBAR MENU -->
		</div>
		<!-- END SIDEBAR -->
		<!-- BEGIN PAGE -->
		<div class="page-content">
 
<?php
require_once('conf/config.php');
 
	if(isset($_POST['table']) && isset($_POST['first']) && isset($_POST['firstval']))
	{
		$table = $_POST['table'];
		$first = $_POST['first'];
		$firstval = $_POST['firstval'];
		unset($_POST['table']);
		unset($_POST['first']);
		unset($_POST['firstval']);
 
		$sets = "";
		foreach ($_POST as $k => $v) {
			if(is_string($v)){ $v = '"'.$v.'"';}
			$sets .= '`'.$k.'`' . ' = ' . $v . ',';
		}
		$sets = substr($sets, 0, -1);
 
		$sql = 'UPDATE `'.$table.'` SET '. $sets .' WHERE '.$first.'='.$firstval.';';
		$res = $db->prepare($sql);
	    if($res->execute()){
	    	echo "Ligne mise à jour !";
	    }else {
	    	echo "Erreur";
	    }
	}
 
	if(isset($_POST['table']) && isset($_POST['ajouter']))
	{
		$table = $_POST['table'];
		unset($_POST['table']);
		unset($_POST['ajouter']);
 
		$sets = "";
		$values = "";
		$cpt = 1;
		foreach ($_POST as $k => $v) {
			if(is_string($v)){ $v = '"'.$v.'"';}
			if($cpt == 1){
				$sets .= $v . ',';
				$values .= '`'.$k . '`,';
			}
			else
			{
				$cpt = 1;
			}
		}
		$sets = substr($sets, 0, -1);
		$values = substr($values, 0, -1);
 
		$sql = 'INSERT INTO `'.$table.'`('.$values.') VALUES ('.$sets.');';
		$res = $db->prepare($sql);
	    if($res->execute()){
	    	echo "Ligne crée !";
	    }else {
	    	echo "Erreur";
	    }
	}
?>
 
 
 
<?php
/*$tables = file_get_contents('conf/tables.txt');
$split = split("/", $tables);
echo '<ul class="nav nav-tabs">';
foreach ($split as $item) {
	echo '<li role="presentation"><a href="dash.php?n='.$item.'">'.$item.'</a></li>';
}
echo '</ul>';

if(isset($_GET['n']) && $_GET['n'] != ""){
	echo '<h1>'.$_GET['n'].' <small><a href="dash.php?n='.$_GET['n'].'&action=add"><span class="glyphicon glyphicon-plus"></span></a></small></h1>';
}*/
 
	if(isset($_GET['n']) && $_GET['n'] != ""){
		echo '<h1>'.$_GET['n'].' <small><a href="dash.php?n='.$_GET['n'].'&action=add"><span class="glyphicon glyphicon-plus"></span><i class="icon-plus"></i></a></small></h1>';
	}
 
/* Gestion suppression */
if(isset($_GET['n']) && isset($_GET['id']) && isset($_GET['action']) && $_GET['action'] == "delete"){
	$sql2 = "SELECT * FROM ".$_GET['n'].";";
	$res2 = $db->prepare($sql2);
    $res2->execute();
    $data2 = $res2->fetchAll(PDO::FETCH_ASSOC);
	$keys2 = array_keys($data2[0]);
	$first2 = null;
	$cp2t = 0;
	foreach ($keys2 as $k2) {
		if($cpt2 == 0){ $first2 = $k2; $cpt2 += 1;}
	}
 
	$deletion = 1;
	$sql = 'DELETE FROM `'.$_GET["n"].'` WHERE '.$first2.'='.$_GET[$first2].';';
	$res = $db->prepare($sql);
    if($res->execute()){
    	echo "Ligne supprimée !";
    }else {
    	echo "Erreur";
    }
}
/* Fin Gestion suppression */
 
/* Gestion edition */
if(isset($_GET['n']) && isset($_GET['id']) && isset($_GET['action']) && $_GET['action'] == "edit"){
	$sql2 = "SELECT * FROM ".$_GET['n'].";";
	$res2 = $db->prepare($sql2);
    $res2->execute();
    $data2 = $res2->fetchAll(PDO::FETCH_ASSOC);
	$keys2 = array_keys($data2[0]);
	$first2 = null;
	$cp2t = 0;
	foreach ($keys2 as $k2) {
		if($cpt2 == 0){ $first2 = $k2; $cpt2 += 1;}
	}
 
	$edition = 1;
	$sql = 'SELECT * FROM `'.$_GET["n"].'` WHERE '.$first2.'='.$_GET[$first2].';';
	$res = $db->prepare($sql);
    $res->execute();
    $data = $res->fetchAll(PDO::FETCH_ASSOC);
	$keys = array_keys($data[0]);
 
	echo '<form method="post" action="dash.php"><div class="row"><table class="table table-striped table-bordered"><tr>';
	$first = null;
	$cpt = 0;
	foreach ($keys as $k) {
		if($cpt == 0){ $first = $k; $cpt += 1;}
		echo '<th>'.$k.'</th>';
	}
	echo '</tr>';
	$nb = 0;
	foreach ($data as $k => $v) {
		echo '<tr>';
		foreach ($v as $key => $value) {
			if($nb == 0){$custom = "disabled"; $nb = 1; $firstval=$value;} else{$custom="";}
			echo '<td><input '.$custom.' type="text" name="'.$key.'" value="'.$value.'"></td>';
		}
		echo '</tr>';
	}
	echo '<input type="hidden" name="table" value="'.$_GET["n"].'">';
	echo '<input type="hidden" name="first" value="'.$first.'">';
	echo '<input type="hidden" name="firstval" value="'.$firstval.'">';
	echo '</table></div><input type="submit" class="btn btn-primary"></form>';
 
}
/* Fin Gestion edition */
 
 
/* Gestion ajout */
if(isset($_GET['n']) && $_GET['action'] == "add"){
	$edition = 1;
	$sql = 'SELECT * FROM `'.$_GET["n"].'` LIMIT 1;';
	$res = $db->prepare($sql);
    $res->execute();
    $data = $res->fetchAll(PDO::FETCH_ASSOC);
	$keys = array_keys($data[0]);
 
	echo '<form method="post" action="dash.php"><table class="table table-striped table-bordered"><tr>';
	$first = null;
	$cpt = 0;
	foreach ($keys as $k) {
		if($cpt == 0){ $first = $k; $cpt += 1;}
		echo '<th>'.$k.'</th>';
	}
	echo '</tr>';
	$nb = 0;
	foreach ($data as $k => $v) {
		echo '<tr>';
		foreach ($v as $key => $value) {
			if($nb == 0){$custom = "disabled"; $nb = 1; $firstval=$value;} else{$custom="";}
			echo '<td><input '.$custom.' type="text" name="'.$key.'" value=""></td>';
		}
		echo '</tr>';
	}
	echo '<input type="hidden" name="table" value="'.$_GET["n"].'">';
	echo '<input type="hidden" name="ajouter" value="1">';
	echo '</table><input type="submit" class="btn btn-primary"></form>';
}
/* Fin Gestion ajout */
 
 
if(isset($_GET['n']) && $deletion != 1 && $edition != 1){
	$sql = "SELECT * FROM ".$_GET['n'];
	$res = $db->prepare($sql);
    $res->execute();
    $data = $res->fetchAll(PDO::FETCH_ASSOC);
 
	$keys = array_keys($data[0]);
	array_push($keys, "Actions");
 
	echo '<table class="table table-striped table-bordered"><tr>';
	$first = null;
	$cpt = 0;
	foreach ($keys as $k) {
		if($cpt == 0){ $first = $k; $cpt += 1;}
		echo '<th>'.$k.'</th>';
	}
	echo '</tr>';
 
	foreach ($data as $k => $v) {
		if($k != "" && $k != null){
			echo '<tr>';
			foreach ($v as $value) {
				echo '<td>'.$value.'</td>';
			}
			echo '<td><a href="dash.php?n='.$_GET["n"].'&'.$first.'='.$v[$first].'&action=edit"><span class="glyphicon glyphicon-pencil"></span><i class="icon-pencil"></i></a> <a href="dash.php?n='.$_GET["n"].'&'.$first.'='.$v[$first].'&action=delete"> <span class="glyphicon glyphicon-trash"></span><i class="icon-trash"></i></a></td></tr>';
		}
	}
	echo '</table>';
}
 
if(!isset($_GET['n'])){
	echo '<br><center><h1>Administration</h1></center>';
	/*echo '<center><p>Created by <a href="http://creationgeek.fr/blog-actu/" target="_blank">Cardinale Anthony</a></p></center>';*/
	echo '<br><br><center><p>Ajoutez ici ce quon veut!!!!!!!!!.</p></center>';	
}
?>
 
 
</div>
		<!-- END PAGE -->
	</div>
	<!-- END CONTAINER -->
	<!-- BEGIN FOOTER -->
	<div class="footer">
		<div class="footer-tools">
			<span class="go-top">
			<i class="icon-angle-up"></i>
			</span>
		</div>
	</div>
	<!-- END FOOTER -->
	<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
	<!-- BEGIN CORE PLUGINS -->   
	<script src="assets/plugins/jquery-1.10.1.min.js" type="text/javascript"></script>
	<script src="assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
	<!-- IMPORTANT! Load jquery-ui-1.10.1.custom.min.js before bootstrap.min.js to fix bootstrap tooltip conflict with jquery ui tooltip -->
	<script src="assets/plugins/jquery-ui/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>      
	<script src="assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
	<!--[if lt IE 9]>
	<script src="assets/plugins/excanvas.min.js"></script>
	<script src="assets/plugins/respond.min.js"></script>  
	<![endif]-->   
	<script src="assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
	<script src="assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>  
	<script src="assets/plugins/jquery.cookie.min.js" type="text/javascript"></script>
	<script src="assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript" ></script>
	<!-- END CORE PLUGINS -->
	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<script src="assets/scripts/app.js" type="text/javascript"></script>
	<script src="assets/scripts/index.js" type="text/javascript"></script>
	<script src="assets/scripts/tasks.js" type="text/javascript"></script>        
	<!-- END PAGE LEVEL SCRIPTS -->  
 
	<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>


Bonne journée à tous