Upload
mohamed-youssfi
View
8.814
Download
20
Embed Size (px)
DESCRIPTION
Développement d'un site web de E-Commerce avec PHP
Citation preview
� Nous souhaitons créer un site Web dynamique qui permet de présenter en ligne le catalogue de produits
� Le catalogue doit présenter des produits. Chaque produit appartient à une catégorie.
� Une catégorie est défini par :� Une code de type INT AUTO_INCREMENT� Un nom Une description� Une description
� Un produit est défini par :� Sa référence de type VARCHAR� Sa designation� Sa quantité en stock� Son prix� Sa photo� Un champ qui indique s’il est disponible� Un champ qui indique s’in est en promotion� Un champ qui indique s’il est sélectionné ou non
Mohamed Youssfi[[email protected]]
� L’application peut être utilisée par les internautes et un administrateur.
� Un internaute trouve dans ce site les possibilités de :
� Afficher les produits sélectionnés (Affichage par défaut)
� Chercher des produits en saisissant un mot clé
� Afficher les produits en promotions
� Afficher les produits d’une catégories
� Ajouter un produit à son panier avec la possibilité de saisir la quantité � Ajouter un produit à son panier avec la possibilité de saisir la quantité de ce produit.
� Afficher le contenu de son panier (Produit, Prix, Quantité, Montant et le montant Total du panier)
� Passer la commande de son panier en saisissant les informations sur le client.
� Un administrateur peu effectuer les opérations suivantes:
� Saisir, Ajouter, consulter, supprimer, éditer, modifier les catégories
� Saisir, Ajouter, Consulter, supprimer, éditer, modifier les produits
Mohamed Youssfi[[email protected]]
� Dessiner l’architecture du site� Proposer une maquette pour ce site (Croquis )
� Base de données :� Concevoir et Créer la base de données nommée DB_BOUTIQUE contenant les tables CATEGORIES et PRODUITS et USERS
� Saisir un utilisateur Admin avec un mot de passe Admin crypté par la fonction MD5.par la fonction MD5.
� Partie back office:� Créer la partie backoffice de l’application qui nécessite l’authentification et contenant les éléments suivants:� Un formulaire d’authentification (Login et Pass)
� Un script de validation de l’utilisateur authentifié
� Un menu qui permet de mener vers les pages qui permettent de:
� Saisir, ajouter, afficher, éditer, modifier et supprimer les catégories
� Saisir, ajouter, afficher, éditer, modifier et supprimer les produits
Mohamed Youssfi[[email protected]]
� Partie front office: boutique virtuelle
� Créer une entête du site qui contient les éléments suivants :
� Un Logo et une zone pour la pub
� Un formulaire de recherche des produits
� Les menus (Produits, Produits en promo, Produits sélectionnés, Panier, etc..)
� Créer la partie gauche du site qui affiche toutes les catégories avec un liens hypertexte qui devrait permettre d’afficher les produits de cette catégories.
� Créer la page qui permet d’afficher les produits selon les critères suivants ;;
� Produits d’une catégories, Produits recherchés, Produits en promotion et Produits sélectionnés (Affichage par défaut) avec la possibilité d’ajouter le produit au panier.
� Créer la page principale du site qui inclut l’ensemble des éléments développés (Entête, Catégories et Produits)
� Créer la page qui permet gérer le panier
� Ajouter dans la base de données les tables nécessaires qui permettent d’enregistrer les commandes d’un client.
� Créer la partie du site qui permet de passer une commande.
� Améliorer le design de votre siteMohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- Database: `DB_DWM_ECOM`
-- Table structure for table `categories`
CREATE TABLE IF NOT EXISTS `categories` (
`CODE_CAT` int (11) NOT NULL AUTO_INCREMENT,`CODE_CAT` int (11) NOT NULL AUTO_INCREMENT,
`NOM_CAT` varchar(25) NOT NULL,
`DESCRIPTION` text NOT NULL,
PRIMARY KEY (`CODE_CAT`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
Mohamed Youssfi[[email protected]]
--
-- Dumping data for table `categories`
--
INSERT INTO `categories` (`CODE_CAT`, `NOM_CAT`, `DESCRIPTION`) VALUES
(1, 'Ordinateurs', 'Ordinateurs'),
(2, 'Imprimantes', ''),
(3, 'Téléphones', ''),
(4, 'Téléviseurs', 'Téléviseurs');
Mohamed Youssfi[[email protected]]
-- Table structure for table `produits`
CREATE TABLE IF NOT EXISTS `produits` (
`REF_PRODUIT` varchar(20) NOT NULL,
`DESIGNATION` varchar(50) NOT NULL,
`QUANTITE` int(11) NOT NULL,
`PRIX` int(11) NOT NULL,
`PHOTO` varchar(30) NOT NULL,
`DISPONIBLE` tinyint(4) NOT NULL,
`PROMOTION` tinyint(4) NOT NULL,
`SELECTIONNE` tinyint(4) NOT NULL,
`CODE_CAT` int(11) NOT NULL,
PRIMARY KEY (`REF_PRODUIT`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Mohamed Youssfi[[email protected]]
-- Dumping data for table `produits`
INSERT INTO `produits` (`REF_PRODUIT`, `DESIGNATION`, `QUANTITE`, `PRIX`, `PHOTO`, `DISPONIBLE`, `PROMOTION`, `SELECTIONNE`, `CODE_CAT`) VALUES
('ORD1', 'Acer aspire intel core i3 deuxeà ¨me génération', 12, 3500, '631502.jpg', 1, 1, 1, 1),
('ORD2', 'Lenovo x201 intel Core i7 écran Tactile', 2, 4500, '631482.jpg', 1, 1, 1, 1),
('ORD3', 'Pc SamSung', 1, 2000, '631627.jpg', 1, 0, 1, 1),
('TEL1', 'Nokia lumia 800 - 16GB', 45, 2400, '638378.jpg', 1, 0, 1, 3),
('Imp1', 'Imprimante Hp Lazer En Bon Etat', 2, 750, '631442.jpg', 1, 0, 1, 2);
', 1);
Mohamed Youssfi[[email protected]]
-- Table structure for table `users`
CREATE TABLE IF NOT EXISTS `users` (
`LOGIN` varchar(20) NOT NULL,
`PASS` varchar(200) NOT NULL,
`NIVEAU` int(11) NOT NULL,
PRIMARY KEY (`LOGIN`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- Dumping data for table `users`
INSERT INTO `users` (`LOGIN`, `PASS`, `NIVEAU`) VALUES
('admin', '21232f297a57a5a743894a0e4a801fc3', 0),
('user', 'ee11cbb19052e40b07aac0ca060c23ee', 1);
Mohamed Youssfi[[email protected]]
Mohamed Youssfi[[email protected]]
<div id="entete">
<table width="100%">
<tr>
<td width="14%" height="89" align="left">
<div id="logo"><img src="images/logo.jpg" width="147" height="71"></div>
</td>
<td width="51%" align="center">
<div id="pub"><img src="images/pub1.jpg" width="529" <div id="pub"><img src="images/pub1.jpg" width="529" height="87"></div>
</td>
<td width="35%" align="right" valign="bottom">
<div id="authentification">
<div>
<?php if(isset($_SESSION['ROLE_USER'])){ ?>
Authentifié avec Login : <?php echo($_SESSION['LOGIN']);?>
<?php }?>
</div>
Mohamed Youssfi[[email protected]]
<div>
<form method="post" action="authentifier.php">
Login : <input type="text" name="login" size="12" />
Pass:<input type="password" name="pass" size="12"/>
<input type="submit" value="OK"/>
</form>
</div>
</div>
</td>
</tr>
</table>
</div>
Mohamed Youssfi[[email protected]]
<div id="menu">
<table width="100%">
<tr>
<td width="24%" valign="top">
<form method="post" action="index.php" id="form2">
<input type="text" name="motCle"/>
<input type="submit" value="Chercher"/>
</form>
</td>
<td width="8%"><a href="index.php">Home</a></td>
<td width="10%"><a href="index.php?promo=1">Promotions</a></td><td width="10%"><a href="index.php?promo=1">Promotions</a></td>
<td width="8%"><a href="index.php">Sélection</a></td>
<td width="7%"><a href="index.php?panier=1">Panier</a></td>
<td width="10%"><a href="index.php">Commander</a></td>
<?php if(isset($_SESSION['ROLE_USER'])){ ?>
<td width="15%"><a href="GestionCategories.php">Gestion Gactégories</a></td>
<td width="17%"><a href="GestionProduits.php">Gestion Produits</a></td>
<?php } ?>
<td width="1%"> </td>
</tr>
</table>
</div>
Mohamed Youssfi[[email protected]]
<?php
session_start();
?>
<!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"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Vente en ligne</title>
<link rel="stylesheet" type="text/css" href="style1.css" />
</head>
Mohamed Youssfi[[email protected]]
<body>
<?php require_once("entete.php")?>
<table width="100%">
<tr>
<td width="22%" valign="top">
<div id="categories">
<?php require_once("categories.php")?>
</div>
</td>
<td width="78%">
<div id="contenu" align="left"><div id="contenu" align="left">
<?php
if(isset($_GET['panier']))
require_once("panier.php");
else
require_once("produits.php")
?>
</div>
</td>
</tr>
</table>
</body>
</html>Mohamed Youssfi[[email protected]]
<?php
$conn=mysql_connect("localhost","root","")or die(mysql_error());
mysql_select_db("DWM_ECOM",$conn)or die(mysql_error());
?>
Mohamed Youssfi[[email protected]]
<?php require_once("connection.php")?>
<?php
$req="select * from CATEGORIES";
$rs=mysql_query($req) or die(mysql_error());
?>
<table>
<?php while($cat=mysql_fetch_assoc($rs)){ ?>
<tr>
<td><td>
<a href="index.php?idCat=<?php echo($cat['CODE_CAT'])?>">
<?php echo($cat['NOM_CAT'])?>
</a>
</td>
</tr>
<?php } ?>
</table>
<?php
mysql_free_result($rs);
?>
Mohamed Youssfi[[email protected]]
<?php require_once("connection.php")?>
<?php
if (isset($_POST['motCle'])){
$motCle=$_POST['motCle'];
$req="select * from PRODUITS where DESIGNATION LIKE
'%$motCle%'";
}
elseif (isset($_GET['idCat'])){
$idCat=$_GET['idCat'];$idCat=$_GET['idCat'];
$req="select * from PRODUITS where CODE_CAT=$idCat";
}
elseif (isset($_GET['promo'])){
$req="select * from PRODUITS where PROMOTION=1";
}
else{
$req="select * from PRODUITS where SELECTIONNE=1";
}
$rsProd=mysql_query($req) or die (mysql_error());
?>
Mohamed Youssfi[[email protected]]
<div id="produits">
<?php while($prod=mysql_fetch_assoc($rsProd)){?>
<div id="produit">
<table>
<tr>
<td>Référence :</td><td><?php echo $prod['REF_PRODUIT']?></td>
<td rowspan="4"><img src="images/<?php echo
$prod['PHOTO']?>"></td>$prod['PHOTO']?>"></td>
</tr>
<tr><td width="80px">Désignation :</td><td width="100px"><?php echo$prod['DESIGNATION']?></td></tr>
<tr><td width="80px">Prix:</td><td><?php echo $prod['PRIX']?></td></tr>
<tr><td width="80px">Quantité:</td><td><?php echo $prod['QUANTITE']?></td>
</tr>
Mohamed Youssfi[[email protected]]
<tr>
<td colspan="3" align="right">
<div id="formPanier">
<form method="post" action="addCaddie.php" id="form2">
<input type="text" name="quantite" size="8" value="1" />
<input type="hidden" name="refProduit" value="<?php echo$prod['REF_PRODUIT']?>" />
<input type="hidden" name="designation" value="<?php echo $prod['DESIGNATION']?>" />
<input type="hidden" name="prix" value="<?php echo $prod['PRIX']?>" /><input type="hidden" name="prix" value="<?php echo $prod['PRIX']?>" />
<input type="image" src="images/panier50.jpg" value="submit" />
</form>
</div>
</td>
</tr>
</table>
</div>
<?php }
mysql_free_result($rsProd);
?>
</div>Mohamed Youssfi[[email protected]]
<?php
session_start();
if(!(isset($_SESSION['panier']))){
$panier=array();
}
else{
$panier=$_SESSION['panier'];
}
$index=count($panier);$index=count($panier);
$panier[$index]['refProduit']=$_POST['refProduit'];
$panier[$index]['prix']=$refProduit;
$panier[$index]['quantite']=$_POST['quantite'];
$panier[$index]['prix']=$_POST['prix'];
$panier[$index]['designation']=$_POST['designation'];
$_SESSION['panier']=$panier;
header("location:index.php?panier=1");
?>
Mohamed Youssfi[[email protected]]
<?php
if(!(isset($_SESSION['panier']))){
$panier=array();
}
else{
$panier=$_SESSION['panier'];
}
?>?>
<table border="1">
<tr>
<th>Ref Produit</th><th>Designation</th><th>Quantité</th>
<th>Prix</th>
</tr>
Mohamed Youssfi[[email protected]]
<?php
$total=0;
for($i=0;$i<count($panier);$i++){
$total=$total+ $panier[$i]['quantite']* $panier[$i]['prix'];
?>
<tr>
<td><?php echo($panier[$i]['refProduit']) ?></td>
<td><?php echo($panier[$i]['designation']) ?></td>
<td><?php echo($panier[$i]['quantite']) ?></td><td><?php echo($panier[$i]['quantite']) ?></td>
<td><?php echo($panier[$i]['prix']) ?></td>
<td><a href="supprimerDuPanier.php?index=<?php echo($i)?>">Supp</a></td>
</tr>
<?php } ?>
<tr>
<td colspan="3">Total:</td><td><?php echo($total)?></td>
</tr>
</table>
<input type="button" value="Commander" onclick="document.location='commander.php'" />
Mohamed Youssfi[[email protected]]
<?php
session_start();
$panier=$_SESSION['panier'];
$index=$_GET['index'];$index=$_GET['index'];
unset($panier[$index]);
$_SESSION['panier']=$panier;
header("location:index.php?panier=1");
?>
Mohamed Youssfi[[email protected]]
<?php require_once("connection.php")?>
<?php
session_start();
$_SESSION=array();
$l=$_POST['login'];
$p=$_POST['pass'];
$pc=md5($p);
$req="select * from USERS where LOGIN='$l' and PASS='$pc'";
$rs=mysql_query($req)or die(mysql_error()); $rs=mysql_query($req)or die(mysql_error());
if($u=mysql_fetch_assoc($rs)){
$_SESSION['ROLE_USER']=$u['NIVEAU'];
$_SESSION['LOGIN']=$l;
header("location:index.php");
}
else{
header("location:index.php");
}
?>
Mohamed Youssfi[[email protected]]
body{
font-family:Georgia, "Times New Roman", Times, serif;
font-size:12px;
}
#logo,#pub,#authentification{
padding:5px;
height:90px;
border:1px dotted #000066;
#categories{border:1px dotted #000066;border-radius:10px 10px 10px 10px;min-height:400px;padding:10px;width:200px;}#contenu{border:1px dotted #000066;border-radius:10px 10px 10px 10px;min-height:400px;
}
#menu{
border:1px dotted #000066;
}
#produit{
border:1px dotted #000066;
border-radius:10px 10px 10px 10px;
float:left;
margin:10px;
padding:10px;
min-height:140px;
}
min-height:400px;padding:10px;}a{text-decoration:none;color:#990000;padding:4px;}a:hover{border:1px solid #990000;background:#FFFF99;}
Mohamed Youssfi[[email protected]]
<?php require_once("connection.php")?>
<?php
session_start();
$req="select * from CATEGORIES";
$rsCat=mysql_query($req) or die(mysql_error());
?>
<!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" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Gestion des catégories</title>
<link rel="stylesheet" type="text/css" href="style1.css" />
<script language="javascript">
function confirmation(idCat){
var rep=confirm("Etes vous sûre de vouloir supprimer cette catégorie ?");
if(rep==true){
document.location="supprimerCategorie.php?idCat="+idCat
}
}
</script>
</head>
Mohamed Youssfi[[email protected]]
<body>
<?php require_once("entete.php")?>
<div id="formCategories" align="center">
<form method="post" action="addCategogie.php">
<table>
<tr>
<td>Nom Catégorie:</td>
<td><input type="text" name="nomCat" /></td>
</tr>
<tr><tr>
<td>Description:</td>
<td><textarea name="description" rows="3" cols="50"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="ajouter" /></td>
</tr>
</table>
</form>
</div>
Mohamed Youssfi[[email protected]]
<div id="listeCategories" align="center">
<table border="1">
<tr>
<th>CODE CAT</th><th>NOM CAT</th><th>Description</th>
</tr>
<?php while($cat=mysql_fetch_assoc($rsCat)){?>
<tr>
<td><?php echo($cat['CODE_CAT'])?></td>
<td><?php echo($cat['NOM_CAT'])?></td>
<td><?php echo($cat['DESCRIPTION'])?></td>
<td>
<a href="javascript:confirmation(<?php echo($cat['CODE_CAT'])?>)">
Supprimer
</a>
</td>
</tr>
<?php } ?>
</table>
</div>
</body>
</html>
Mohamed Youssfi[[email protected]]
<?php require_once("connection.php")?>
<?php
$nc=$_POST["nomCat"]; $d=$_POST["description"];
$req="insert into CATEGORIES (NOM_CAT,DESCRIPTION) values ('$nc','$d')";
mysql_query($req) or die(mysql_error());mysql_query($req) or die(mysql_error());
header("location:GestionCategories.php")
?>
Mohamed Youssfi[[email protected]]
<?php require_once("connection.php")?>
<?php
$idc=$_GET["idCat"];
$req="delete from CATEGORIES where CODE_CAT=$idc";
mysql_query($req) or die(mysql_error());
header("location:GestionCategories.php")header("location:GestionCategories.php")
?>
Mohamed Youssfi[[email protected]]
<?php require_once("connection.php")?>
<?php
session_start();
$req="select * from CATEGORIES";
$rsCat=mysql_query($req) or die(mysql_error());
?>
<!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>Gestion des catégories</title>
<link rel="stylesheet" type="text/css" href="style1.css" />
</head>
Mohamed Youssfi[[email protected]]
<body>
<?php require_once("entete.php")?>
<div id="formProduits" align="center">
<form method="post" action="addProduit.php" enctype="multipart/form-data">
<table>
<tr>
<td>REF Produit:</td><td>REF Produit:</td>
<td><input type="text" name="refProduit" /></td>
</tr>
<tr>
<td>Designation:</td>
<td><input type="text" name="designation" /></td>
</tr>
Mohamed Youssfi[[email protected]]
<tr>
<td>Catégorie:</td>
<td>
<select name="idCat">
<?php while($cat=mysql_fetch_assoc($rsCat)){?>
<option value="<?php echo($cat['CODE_CAT'])?>">
<?php echo($cat['NOM_CAT'])?>
</option></option>
<?php }?>
</select>
</td>
</tr>
<tr>
<td>Quantité:</td><td><input type="text" name="quantite" /></td>
</tr>
<tr>
<td>Prix:</td><td><input type="text" name="prix" /></td>
</tr>Mohamed Youssfi[[email protected]]
<tr>
<td>Photo:</td><td><input type="file" name="photo" /></td>
</tr>
<tr>
<td>Disponible:</td><td><input type="checkbox" name="disponible" checked="checked" /></td>
</tr>
<tr>
<td>En Promotion:</td><td><input type="checkbox" name="promotion" /></td>
</tr>
<tr><tr>
<td>Sélectionné:</td><td><input type="checkbox" name="selectionne" checked="checked"/></td>
</tr>
<tr>
<td><input type="submit" value="Ajouter" /></td>
</tr>
</table>
</form>
</div>
</body>
</html>Mohamed Youssfi[[email protected]]
<?php require_once("connection.php")?>
<?php
$ref=$_POST["refProduit"]; $des=$_POST["designation"];
$idCat=$_POST["idCat"]; $prix=$_POST["prix"]; $quantite=$_POST["quantite"];
$nomPhoto=$_FILES['photo']['name'];
$fichierTemporaire=$_FILES['photo']['tmp_name'];
move_uploaded_file($fichierTemporaire,"./images/$nomPhoto");
if(isset($_POST['promotion'])) $promo=1; else $promo=0; if(isset($_POST['promotion'])) $promo=1; else $promo=0;
if(isset($_POST['selectionne'])) $sel=1; else $sel=0;
if(isset($_POST['disponible'])) $dispo=1; else $dispo=0;
$req="insert into PRODUITS(REF_PRODUIT,DESIGNATION,QUANTITE,PRIX,PHOTO,
DISPONIBLE,PROMOTION,SELECTIONNE,CODE_CAT)
values ('$ref','$des',$quantite,$prix,'$nomPhoto',$dispo,$promo,$sel,$idCat)";
mysql_query($req) or die(mysql_error());
?>
Mohamed Youssfi[[email protected]]
<html> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<?php require_once("entete.php")?>
<h3> Données Enregistrées avec succés</h3>
<table border="1">
<tr> <td>REF :</td><td><?=$ref?> </td> </tr>
<tr> <td>Designation :</td><td><?=$des?> </td></tr>
<tr> <td>Photo :</td><td><img src="images/<?=$nomPhoto?>" width="100" height="50"/></td></tr>
<tr> <td>Prix :</td><td><?=$prix?> </td> </tr><tr> <td>Prix :</td><td><?=$prix?> </td> </tr>
<tr> <td>Quantité :</td><td><?=$quantite?> </td> </tr>
<tr> <td>Code Catégorie :</td><td><?=$idCat?> </td> </tr>
<tr> <td>Disponible :</td><td><?=$dispo?> </td> </tr>
<tr> <td>Promotion :</td><td><?=$promo?> </td> </tr>
<tr> <td>Sélectionné :</td><td><?=$sel?> </td> </tr>
</table>
<a href="index.php">Home</a>
</body></html>
<?php
mysql_close($conn);
?> Mohamed Youssfi[[email protected]]