Bonjour je viens de développer une page web pour le payement par carte les produits d’un shopping. Le nom de cette page est carte.php dont voici le code :

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
<?php
session_start(); 
	$database_name = "details_produit";
	$con = mysqli_connect("localhost", "root", "ser45", $database_name);
 
 
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Carte de Shopping</title>
 
<link href="httpsmaxcdn.bootstrapcdn.combootstrap3.3.7cssbootstrap.min.css" rel="stylesheet" />
<script src="httpsmaxcdn.bootstrapcdn.combootstrap3.3.7jsbootstrap.min.js"></script>
 
<style>
@import('https://fonts.googleapis.com/css?family=Titillium+Web');
 
	*{
		font-family: 'Titillium Web', sans-serif;
	}
	.produit{
		border: 1px solid #eaeaec;
		margin: -1px 19px 3px -1px;
		padding: 10px;
		text-align:center;
		background-color: #efefef;
	}
	table, th, tr{
		text-align:center;
	}
	.title2{
		text-align: center;
		color: #66afe9;
		background-color: #efefef;
		padding: 2%;
	}
	tableth{
		background-color: #efefef;
	}
</style>
 
</head>
 
<body>
 
<div class="container" style="width: 65%">
<h2>Shopping Cart</h2>
<?php
		    $query = "SELECT * FROM Produit ORDER BY id ASC";
		    $result = mysqli_query($con, $query);
		if(mysqli_num_rows($result) > 0){
 
			while ($row = mysqli_fetch_array($result)){
 
				    ?>	
		<div class="col-md-3">
 
<form method="post" action=carte.php"?action=addδid=<?php echo $row["id"] ?>">
 
<div class="produit">
<imgsrc="<?php echo $row["image"]; ?>" class="img-responsive">
<h5 class="text-info"><?php $row["pnom"]; ?></h5>
<h5 class="text-danger"><?php $row["prix"]; ?></h5>
<input type="text" name="quantité" class="form-control" value="1" />
<input type="hidden" name="hidden_name" value="<?php echo $row["pnom"]; ?>" />
<input type="hidden" name="hidden_name" value="<?php echo $row["prix"]; ?>" />
<input type="submit" name="add" style="margin-top: 5px;" class="btnbtn-success" value="Ajouter à la carte" />
</div>
</form>
</div>
<?php
		        }
		    }
	    ?>
 
<div style="clear:both"></div>
<h3 class="title2">Carte Shopping Details</h3>
<div class="table table-bordered">
<tr>
<th width="38%">Nom Produit</th>
<th width="18%">Quantité</th>
<th width="13%">Detail prix</th>
<th width="17%">Supprimer Menu</th>
</tr>
 
<?php
			if(!empty($_SESSION["carte"])){
					$total = 0;
					foreach ($_SESSION["carte"] as $key => $value){
						?>
<tr>
<td><?php echo $value["menu_nom"]; ?></td>
<td><?php echo $value["menu_quantite"]; ?></td>
<td>$ <?phpecho $value["prix_produit"]; ?></td>
<td>
                                $ <?phpechonumber_format($value["menu_quantite"] * $value["prix_produit"], 2); ?></td>
<td><a href="carte.php?action=deleteδid=<?php echo $value["id_produit"]; ?>"><span class="text-danger">Supprimer Menu</span></a></td>
</tr>
<?php
						$total = $total + ($value["menu_quantite"] * $value["prix_produit"]);
					}
						?>
<tr>
<td colspan="3" align="right">Total</td>
<td></td>
</tr>
<?php
 
					}
            ?>
</div>
 
</div>
 
 
</body>
</html>
Lorsque j’ouvre le navigateur firefox, il m’affiche le message :
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\projects\carte shopping\carte.php on line 4

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\projects\carte shopping\carte.php on line 53

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\projects\carte shopping\carte.php on line 54
Voice ma base de données que j’ai créé:
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
-- phpMyAdmin SQL Dump
-- version 4.1.4
-- <a href="http://www.phpmyadmin.net" target="_blank">http://www.phpmyadmin.net</a>
--
-- Client :  127.0.0.1
-- Base de données :  `details_produits`
--
 
-- --------------------------------------------------------
 
--
-- Structure de la table `produit`
--
 
CREATE TABLE IF NOT EXISTS `produit` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
`pnom` varchar(255) DEFAULT NULL,
  `image` varchar(255) DEFAULT NULL,
  `prix` double DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
 
--
-- Contenu de la table `produit`
--
 
INSERT INTO `produit` (`id`, `pnom`, `image`, `prix`) VALUES
(1, 'Sac Laptop', 'sac laptop.png', 15.08),
(2, 'Vivo v5', 'vivo-v5.png', 232.92),
(3, 'Phillips', 'tondeuse.png', 24.08),
(4, 'Iphone 6s', 'iphone6s.png', 399.26);