bonjour a tous je suis a la limite de me tirer les cheveux...

j'ai une page que j'ai creer sous php je voudrai le mettre en forme mais je n'arrive pas pouvez vous m'aider a le faire merci voici la premiere page que j'ai fais


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
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
 
 
<link href="../style/bootstrap.css" type="text/css" rel="stylesheet"/>
<?php
 
session_start();
 
?>
 
		<h1>Bienvenue, <?php echo $_SESSION['username']; ?></h1>
		<br/>
		<a href="?action=add">Ajouter un priduit |</a>
		<a href="?action=modifyanddelete"> Modifier / Supprimer un priduit</a><br/><br/>
 
		<a href="?action=add_category"> Ajouter une categorie |</a>
		<a href="?action=modifyanddelete_category"> Modifier / Supprimer une categorie</a><br/><br/>
 
		<a href="?action=options">Options</a><br/><br/>
		<a href="../fonctions/deconnexion.php">Deconnexion</a><br/><br/>
 
 
<?php
try{
		$db=new PDO ('mysql:host=127.0.0.1;dbname=e-commerce', 'root','');
		$db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); //les noms des champs seront en caracteres minuscules
		$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);//les erreurs lanceront des exceptions
		}
		catch(Exception $e){
			//var_dump($e);
			die('Une erreur est survenue');
		}
 
if(isset($_SESSION['username'])){
 
	if(isset($_GET['action'])){
 
		if($_GET['action']=='add'){
 
 
			if(isset($_POST['submit'])){
				//var_dump($_POST);
				$stock=$_POST['stock'];
				$title=$_POST['title'];
				$description=$_POST['description'];
				$price=$_POST['price'];
 
				$img = $_FILES['img']['name'];
				$img_tmp = $_FILES['img']['tmp_name'];
 
				if(!empty($img_tmp)){
 
					$image=explode('.',$img);
 
					$image_ext=end($image);
 
					if(in_array(strtolower($image_ext),array('png','jpg','jpeg'))===false){
 
 
						echo 'Veuillez un fichier ayant pour extenssion : pgn, jpg ou jpeg';
					}else{
 
 
						$image_size=getimagesize($img_tmp);
 
						if($image_size['mime']=='image/jpeg'){
 
 
							$image_src = imagecreatefromjpeg($img_tmp);
						}else if($image_size['mime']=='image/png'){
 
 
							$image_src = imagecreatefrompng($img_tmp);
						}else{
 
							$image_src=false;
							echo 'Veuillez entrer une image valide';
 
						}
 
						if($image_src!==false){
 
 
							$image_width=200;
							if($image_size[0]==$image_width){
 
								$image_finale=$image_src;
 
							}else{
 
 
								$new_width[0]=$image_width;
								$new_height[1] = 200;
								$image_finale=imagecreatetruecolor($new_width[0], $new_height[1]);
								imagecopyresampled($image_finale, $image_src, 0,0,0,0, $new_width[0],$new_height[1], $image_size[0], $image_size[1]);
							}
							imagejpeg($image_finale,'imgs/'.$title.'.jpg');
						}
 
					}
 
 
 
 
				}else{
 
 
					echo 'Veuillez selectionner une image.';
 
				}
 
				if ($title&&$description&&$price&&$stock){
 
					$category=$_POST['category'];
					$weight=$_POST['weight'];
					//$shipping=$_POST['price']
 
					$select=$db->query("SELECT price FROM weights WHERE name='$weight'");
 
					$s=$select->fetch(PDO::FETCH_OBJ);
					$shipping=$s->price;
 
					$old_price=$price;
 
					//$totalht=1+$tva%
					$Final_price = $old_price + $shipping;
 
					$select=$db->query("SELECT tva FROM products");
 
					$s1=$select->fetch(PDO::FETCH_OBJ);
 
					$tva=$s1->tva;
 
					$final_price_1 = $Final_price+$Final_price*$tva/100;
 
					$insert=$db->prepare("INSERT INTO products VALUES('','$title','$description','$price', '$category', '$weight', '$shipping' ,'$tva','$final_price_1','$stock')");
					$insert->execute();
				}else{
 
					echo 'Veuillez remplir tous les champs';
				}
			}			
		?>
 
			<form action="" method="post" enctype="multipart/form-data">
			<h3>Titre du produit :</h3><input type="text" class="form-control" name="title"/>
			<h3>Description du produit :</h3><textarea name="description"/></textarea>
			<h3>Prix :</h3><input type="text" name="price"/><br/><br/>
			<h3>Image :</h3>
			<input type="file" name="img"/><br/><br/>
			<h3>Categorie :</h3><select name="category">
 
			<?php $select=$db->query("SELECT * FROM category");
 
				while ($s=$select->fetch(PDO::FETCH_OBJ)){
 
 
				?>
 
				<option>
 
				<?php echo $s->name;?>
 
 
 
				</option>
 
				<?php
				}
 
 
			?>
 
 
 
			</select><br/><br/>
 
			<h3>Poid plus de :</h3><select name="weight">
 
			<?php 
 
				$select=$db->query("SELECT * FROM weights");
 
				while ($s=$select->fetch(PDO::FETCH_OBJ)){
 
 
			?>
 
				<option>
 
				<?php echo $s->name;?>
 
 
 
				</option>
 
				<?php
				}
 
 
			?>
 
 
			</select><br/><br/>
			<h3>Stock :</h3>
			<input type="text" name="stock"/><br/>
			<input type="submit" name="submit" value="Valider"/>
			</form>
 
		<?php
 
		}else if ($_GET['action']=='modifyanddelete'){
 
			$select=$db->prepare("SELECT * FROM products");
			$select->execute();
 
			while ($s=$select->fetch(PDO::FETCH_OBJ)){
 
				echo $s->title;
				?>
 
				<a href="?action=modify&amp;id=<?php echo $s->id; ?>">Modifier</a>
				<a href="?action=delete&amp;id=<?php echo $s->id; ?>">X</a><br/><br/>
 
				<?php
			}
 
		}else if ($_GET['action']=='modify'){
 
 
 
			$id=$_GET['id'];
			$select=$db->prepare("SELECT * FROM products WHERE id=$id");
			$select->execute();
 
			$data=$select->fetch(PDO::FETCH_OBJ);
 
 
			?>
			<form action="" method="post">
			<h3>Titre du produit :</h3><input value="<?php echo $data->title;?>" type="text" name="title"/>
			<h3>Description du produit :</h3><textarea  name="description"/><?php echo $data->description;?></textarea>
			<h3>Prix :</h3><input value="<?php echo $data->price;?>" type="text" name="price"/>
			<h3>Stock :</h3><input type="text" value="<?php echo $data->stock;?>" name="stock"/><br/>
			<input type="submit" name="submit" value="Modifier"/>
			</form>
 
			<?php
 
			if(isset($_POST['submit'])){
 
				$stock=$_POST['stock'];
				$title=$_POST['title'];
				$description=$_POST['description'];
				$price=$_POST['price'];
 
				$update=$db->prepare("UPDATE products SET title='$title', description='$description', price='$price', stock='$stock' WHERE id=$id");
				$update->execute();
 
				header('location: admin.php?action=modifyanddelete');
			}
 
		}else if($_GET['action']=='delete'){
 
			$id=$_GET['id'];
			$delete=$db->prepare("DELETE FROM products WHERE id=$id");
			$delete->execute();
 
 
 
		}else if($_GET['action']=='add_category'){
 
			if(isset($_POST['submit'])){
 
 
				$name= $_POST['name'];
 
					if($name){
						$insert=$db->prepare("INSERT INTO category VALUES('','$name')");
						$insert->execute();
 
					}else{
 
						echo 'Veuillez remplir tous les champs';
 
 
					}
			}
 
			?>
 
			<form action="" method="post">
			<h3>Titre de la categorie :</h3>
			<input type="text" name="name"/><br/><br/>
			<input type="submit" name="submit" value="Ajouter" />
 
			 </form>
 
 
 
			<?php
 
 
 
		}else if($_GET['action']=='modifyanddelete_category'){
 
 
			$select=$db->prepare("SELECT * FROM category");
			$select->execute();
 
			while ($s=$select->fetch(PDO::FETCH_OBJ)){
 
				echo $s->name;
				?>
 
				<a href="?action=modify_category&amp;id=<?php echo $s->id; ?>">Modifier</a>
				<a href="?action=delete_category&amp;id=<?php echo $s->id; ?>">X</a><br/><br/>
 
				<?php
			}
 
 
		}else if($_GET['action']=='modify_category'){
 
			$id=$_GET['id'];
			$select=$db->prepare("SELECT * FROM category WHERE id=$id");
			$select->execute();
 
			$data=$select->fetch(PDO::FETCH_OBJ);
 
 
			?>
			<form action="" method="post">
			<h3>Nom de la categorie :</h3><input value="<?php echo $data->name;?>" type="text" name="title"/>
			<input type="submit" name="submit" value="Modifier"/>
			</form>
 
			<?php
 
			if(isset($_POST['submit'])){
 
 
				$title=$_POST['title'];
 
				$update=$db->prepare("UPDATE category SET name='$title' WHERE id=$id");
				$update->execute();
 
				header('location: admin.php?action=modifyanddelete_category');
			}
 
 
 
		}else if($_GET['action']=='delete_category'){
 
			$id=$_GET['id'];
			$delete=$db->prepare("DELETE FROM category WHERE id=$id");
			$delete->execute();
 
			header('location: admin.php?action=modifyanddelete_category');
			}else if($_GET['action']=='options'){
 
				?>
					<h2>Frais de port : </h2><br/>
					<h3>Options de poids (plus de)</h3>
 
				<?php
 
				$select=$db->query("SELECT * FROM weights");
 
				while ($s=$select->fetch(PDO::FETCH_OBJ)){
 
 
					?>
 
					<form action="" method="post">
					<input type="text" name="weight" value="<?php echo $s->name;?>"/><a href="?action=modify_weight&amp;name=<?php echo $s->name;?>"> Modifier</a>
					</form>
 
					<?php
 
				}
					$select=$db->query("SELECT tva FROM products");
 
					$s=$select->fetch(PDO::FETCH_OBJ);
 
					if(isset($_POST['submit2'])){
 
						$tva=$_POST['tva'];
 
						if($tva){
 
							$update=$db->query("UPDATE products SET tva=$tva");
 
						}
 
 
					}
 
 
				?>
					<h3>TVA :</h3>
					<form action="" method="post"> 
					<input type="test" name="tva" value="<?php echo $s->tva;?>"/>
					<input type="submit" name="submit2" value="modifier"/>
					</form>
					<?php
 
			}else if($_GET['action']=='modify_weight'){
 
				$old_weight=$_GET['name'];
				$select=$db->query("SELECT * FROM weights WHERE name=$old_weight");
				$s=$select->fetch(PDO::FETCH_OBJ);
 
 
				if(isset ($_POST['submit'])){
 
 
					$weight=$_POST['weight'];
					//$old_price=$_GET['price'];
					$price=$_POST['price'];
 
					if($weight&&$price){
 
						$update=$db->query("UPDATE weights SET name='$weight', price='$price' WHERE name=$old_weight");
 
 
						header('location:admin.php?action=options');
 
						//$s->fetch(PDO::FETCH_OBJ);
						//$update->execute();
 
					}
 
					}
				?>
					<h2>Frais de port : </h2><br/>
					<h3>Options de poids (plus de)</h3>
 
					<form action="" method="post">						
					<h3>Poid (plus de) : </h3><input type="text" name="weight" value="<?php echo $_GET['name'];?>"/><br/>
					<h3>Correspond a : </h3><input type="text" name="price" value="<?php echo $s->price;?>"/> <h3>Euros</h3><br/>
					<input type="submit" name="submit" value="Modifier">
 
 
					</form>
 
				<?php
 
 
 
 
			}else{
 
			die('Une erreure s\'est produite.');
 
			}
 
		}else{
 
			}
 
		}else{
 
 
			header('location: ../index.php');
		}
 
		?>
et voila ou je voudrai tous placer.

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
 
 
<?php
include_once('../includes/initadmin.php');
include_once('../includes/headadmin.php');
include_once('../includes/headeradmin.php');
//include_once('../includes/fonctions_admin.php');
?>
 
 
 
<body>
    <center><h1 style="color:white">Bienvenue, <?php echo $_SESSION['username']; ?> vous etes sur la partie administration.</h1></center>
        <br/>
        <div class="systeme_onglets">
        <div class="onglets">
            <span class="onglet_0 onglet" id="onglet_quoi" onclick="javascript:change_onglet('quoi');">Produit</span>
            <span class="onglet_0 onglet" id="onglet_qui" onclick="javascript:change_onglet('qui');">Categorie</span>
            <span class="onglet_0 onglet" id="onglet_pourquoi" onclick="javascript:change_onglet('pourquoi');">TVA</span>
            <span class="onglet_0 onglet" id="onglet_logo" onclick="javascript:change_onglet('pourquoi');">LOGO</span>
        </div>
        <div class="contenu_onglets">
            <div class="contenu_onglet" id="contenu_onglet_quoi">
                <center><h1>Gestion des produits</h1></center><br/><br/>
                <center><u>Cette partie va permettre de gerer les produits.</u></center><br/><br/>
                <ul>
                    <li><a href="?action=add">Ajouter un produit</a></li>
                    <li><a href="?action=modifyanddelete"> Modifier / Supprimer un produit</a><br/><br/></li>
              </ul>
 
            </div>
            <div class="contenu_onglet" id="contenu_onglet_qui">
                <center><h1>Gestion des categories</h1></center><br/><br/>
                <center><u>Cette partie va permettre de gerer les categories.</u></center><br/><br/>
               <ul>
                    <li><a href="?action=add_category"> Ajouter une categorie</a></li>
 
                    <li><a href="?action=modifyanddelete_category"> Modifier / Supprimer une categorie</a><br/><br/></li>
                </ul>
            </div>
            <div class="contenu_onglet" id="contenu_onglet_pourquoi">
                <center><h1>TVA</h1></center><br/><br/>
                <center><u>Cette partie va permettre de TVA s'il ya lieu.</u></center><br/><br/>
 
 
               <?php
 
 
                    $select=$db->query("SELECT tva FROM products");
 
                    $s=$select->fetch(PDO::FETCH_OBJ);
 
                    if(isset($_POST['submit2'])){
 
                        $tva=$_POST['tva'];
 
                        if($tva){
 
                            $update=$db->query("UPDATE products SET tva=$tva");
 
                        }
 
 
                    }
 
 
                ?>
                    <center><h3>Modidication de taux de TVA :</h3>
                    <form action="" method="post"> 
                    <input style="width: 100px" type="test" name="tva" value="<?php echo $s->tva;?>"/><br/>
                    <input style="background: blue" type="submit" name="submit2" value="modifier le taux de TVA"/>
                    </form><center>
            </div>
 
 
        </div>
    </div>
    <script type="text/javascript">
        //<!--
                var anc_onglet = 'quoi';
                change_onglet(anc_onglet);
        //-->
        </script>
        <center><a href="../fonctions/deconnexion.php">Deconnexion</a><br/><br/></center>
<?php echo tauxtva();
//var_dump(tauxtva());
?>
 
</body>
 
</html>
j'ai reussi pour la tva mais pas pour le reste merci d'avance