0% ont trouvé ce document utile (0 vote)
283 vues8 pages

Authentification et Gestion de Produits

Transféré par

Aymen Fayachi
Copyright
© Attribution Non-Commercial (BY-NC)
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
283 vues8 pages

Authentification et Gestion de Produits

Transféré par

Aymen Fayachi
Copyright
© Attribution Non-Commercial (BY-NC)
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd

Correction TP Partie 1 1 Enseignant : Mr.

ABBASSI Kamel

Correction TP Partie 1
Tp partie
1

[Link] [Link] [Link] [Link] [Link] [Link] [Link] [Link] [Link]

Fichier : [Link]
Auteur : Mr. ABBASSI Kamel

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


"[Link]
<html>
<head>
<title>Page protegée par mot de passe :Administrateur</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<center><h3>BACK OFFICE</h3>
<h3>Page protegée par mot de passe</h3>
<h5>Viellez saisir votre Login et mot de passe</h5>
<form action="[Link]" method="POST" name="autontification">
<table border="1" bgcolor="#FF0033">
<tr><td>Login:</td><td><input type="text" name="login"></td></tr>
<tr><td>Pass:</td><td><input type="password" name="pass"></td></tr>
</table>
<input type="submit" value="Envoyer"> &nbsp; &nbsp;<input type="reset" value="Effacer">
</form>
</center>
<?php
include('[Link]');
if(isset($_POST['login']) and isset($_POST['pass']))
{
if($_POST['login']=='administrateur' and $_POST['pass']=='scoop')
header( "location: [Link]");
else
{
header("location :[Link]");
alerte('Mot de passe incorrecte');
//echo "<center> Mot de passe incorrect</center>";
}
}

?>
</body>
</html>
Correction TP Partie 1 2 Enseignant : Mr. ABBASSI Kamel

Fichier : [Link]
Auteur : Mr. ABBASSI Kamel

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


"[Link]
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


</head>
<center>
<h4>Nous somme le :<?php echo date("d m Y",time());?></h4>
<h3>Choisir une action </h3>
<a href="[Link]">Ajouter produit</a> &nbsp;&nbsp;<a href="[Link]">Chercher produit</a>
&nbsp;&nbsp;<a href="[Link]">Lister les produits</a>
<hr width="50%">
</center>
<body>
</body>
</html>

Fichier : fonctions. php


Auteur : Mr. ABBASSI Kamel

<?php
//fonction pour la connexion au serveur et la base
function connexion(){
mysql_connect('localhost','root','') or die('Impossible d\'accerder auserveur');
mysql_select_db('scoop') or die('Imppossible d\'acceder à la base');
}

function alerte($ch)
{
$code="<script type=\"text/javascript\">";
$code.="alert('$ch');";
$code.="</script>";
echo $code;
}
function deconnexion()
{
mysql_close();
}
?>
Correction TP Partie 1 3 Enseignant : Mr. ABBASSI Kamel

Fichier : [Link]
Auteur : Mr. ABBASSI Kamel

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


"[Link]
<html>
<head>
<title>Gesion produits </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<center> <h4>Bienvenue Administrateur </h4></center>
<?php include('[Link]') ?>
</body>
</html>

Fichier : [Link]
Auteur : Mr. ABBASSI Kamel

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


"[Link]
<html>
<head>
<title>Ajouter un produit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php include('[Link]');
include('[Link]');
?>
<center>
<h3>Ajouter un nouveau produit</h3>
<form action="[Link]" method="POST">
<table border="1" bgcolor="#99CCFF">
<tr><th>Catégorie</th><td><select name="cat">
<option value="PC">Ordinateur Personnel</option>
<option value="Souris">Souris</option>
<option value="Carte mere">Carte mere</option>
<option
value="Clavier">Clavier</option></select></td></tr>

<tr><th>Réference:</th><td><input type="text" name="ref"></td></tr>


<tr><th>Nom:</th><td><input type="text" name="nom"></td></tr>
<tr><th>Marque:</th><td><input type="text" name="marque"></td></tr>
<tr><th>Prix:</th><td><input type="text" name="prix"></td></tr>
</table>
<br>
Correction TP Partie 1 4 Enseignant : Mr. ABBASSI Kamel

<input type="submit" value="Ajouter"> &nbsp;&nbsp;<input type="reset" value="Effacer">


</form>
</center>
<?php

if(isset($_POST['cat']) and isset($_POST['ref']) and isset($_POST['nom']) and isset($_POST['marque']) and


isset($_POST['prix']))
{
if(!empty($_POST['cat']) or !empty($_POST['ref']) or !empty($_POST['nom']) or
!empty($_POST['marque']) and !empty($_POST['prix']))
{
connexion();
$sql1="select * from produit where ref='".$_POST['ref']."'";
$resultat=mysql_query($sql1) or die('erreur exec recet');
if(mysql_num_rows($resultat)==0)
{
$sql2="insert into produit
values('".$_POST['ref']."','".$_POST['cat']."','".$_POST['nom']."','".$_POST['marque']."','".$_POST['prix']."')";
mysql_query($sql2);
deconnexion();
alerte("Le produit".$_POST['nom']." est ajouté avec succés");
}
else
alerte('le produit existant');
}
else
alerte('Remplir les champs');
}
else
//alerte('Les variables non existants');
?>
</body>
</html>

Fichier : [Link]
Auteur : Mr. ABBASSI Kamel
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[Link]
<html>
<head>
<title>Chercher un produit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php include('[Link]');
include('[Link]'); ?>
<center>
<h3>Rechercher un produit</h3>
Correction TP Partie 1 5 Enseignant : Mr. ABBASSI Kamel

<form action="[Link]" method="POST">


<table border="1" bgcolor="#FF9966">
<tr><td>Mot Clé: </td><td><input type="text" name="mc"></td></tr>
</table>
<br>
<input type="submit" value="Rechercher"> &nbsp;&nbsp;<input type="reset" value="Annuler">
</form>

</center>
<?php
if(isset($_POST['mc'])) // variable existant
{
if(!empty($_POST['mc'])) //champs non vide
{
connexion();
$sql1="select * from produit where ref='".$_POST['mc'].
"' or nom='".$_POST['mc']."' or marque='".$_POST['mc'].
"' or prix='".$_POST['mc']."' or cat='".$_POST['mc']."'";

$resultat=mysql_query($sql1) or die('erreur dans le requete');


echo "<center> <b>Il y a ".mysql_num_rows($resultat)." Produit(s)</b></center>";
?>
<center><table border="1">
<tr
bgcolor="#99FF33"><th>Catégorie</th><th>Réference</th><th>Nom</th><th>Marque</th><th>Prix</th><th
>Modifier / Supprimer</th></tr>
<?php
while($enreg=mysql_fetch_array($resultat))
{//debut de while
?>
<tr><td><?php echo $enreg['cat']; ?></td>
<td><?php echo $enreg['ref']; ?></td>
<td><?php echo $enreg['nom']; ?></td>
<td><?php echo $enreg['marque']; ?></td>
<td><?php echo $enreg['prix']; ?></td>
<td><a href="[Link]?reference=<?php echo $enreg['ref'];?>">Modifier</a>
&nbsp;<a href="[Link]?reference=<?php echo $enreg['ref'];?>">Supprimer</a></td>
</tr>

<?php
} // fin de while
echo "</table>";
deconnexion();
} // fin de if de champs vide
else // si le champs mc est vide
alerte('Taper un mot cle');
} //fin de if de variable existants
?>
</body>
</html>
Correction TP Partie 1 6 Enseignant : Mr. ABBASSI Kamel

Fichier : [Link]
Auteur : Mr. ABBASSI Kamel
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[Link]
<html>
<head>
<title>Modifier un produit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php include('[Link]'); include('[Link]');
if(isset($_GET['reference']))
{
connexion();
$sql1="select * from produit where ref='".$_GET['reference']."'";
$r1=mysql_query($sql1);
while($enreg=mysql_fetch_array($r1))
{
?>

<center>
<h3>Modification du produit : <?php echo $_GET['reference'] ?></h3>
<form action="[Link]" method="post">
<table border="1">
<tr><td bgcolor="#00FF99">Nom</td><td><input type="text" name="nom"
value="<?php echo $enreg['nom']; ?>"></td></tr>
<tr><td bgcolor="#00FF99">Marque</td><td><input type="text"
name="marque" value="<?php echo $enreg['marque']; ?>"></td></tr>
<tr><td bgcolor="#00FF99">Prix</td><td><input type="text" name="prix"
value="<?php echo $enreg['prix']; ?>"></td></tr>
</table>
<input type="submit" value="Modifier"> &nbsp;&nbsp;<input type="reset" value="Annuler">
<input type="hidden" name="reference" value="<?php echo $_GET['reference']; ?>">
</form>
</center>

<?php
deconnexion();
}
}
// mise à jour de produit
if(isset($_POST['nom']) and isset($_POST['marque']) and isset($_POST['prix']))
{
connexion();
alerte('connexion avec succés');
$sql="update produit set nom='".$_POST['nom']."', marque='".$_POST['marque']."',
prix='".$_POST['prix']."' where ref= '".$_POST['reference']."'";
mysql_query($sql);
alerte('La modification est fait avec succés');
Correction TP Partie 1 7 Enseignant : Mr. ABBASSI Kamel

?>
</body>
</html>

Fichier : [Link]
Auteur : Mr. ABBASSI Kamel

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


"[Link]
<html>
<head>
<title>Supprission de produit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
include('[Link]');
connexion();
$sql="delete from produit where ref='".$_GET['reference']."'";
mysql_query($sql) or die('Erreur de supprission de produit');
echo "<center>Le produit :".$_GET['reference']." est supprimé avec succés</center>";
?>
</body>
</html>

Fichier : [Link]
Auteur : Mr. ABBASSI Kamel
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[Link]
<html>
<head>
<title>Lister trier les produits</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php include('[Link]'); include('[Link]');?>
<center>
<p>
<form name="trie" action="[Link]" method="post">
Catégorie <input type="radio" name="t" value="cat"> &nbsp;&nbsp;
Nom <input type="radio" name="t" value="nom">&nbsp;&nbsp;
Marque <input type="radio" name="t" value="marque">&nbsp;&nbsp;
Prix <input type="radio" name="t" value="prix">
Correction TP Partie 1 8 Enseignant : Mr. ABBASSI Kamel

</p>
<p>
<input type="submit" value="Trier"></p>
</form>
<?php
if(isset($_POST['t']))
{
switch($_POST['t']){
case 'cat' :trie('cat');break;
case 'marque' :trie('marque');break;
case 'nom' :trie('nom');break;
case 'prix' :trie('prix');break;
}
}
function trie($var){
connexion();
$sql="select * from produit order by ".$var;
$resultat=mysql_query($sql);
echo "<table border=1>";
echo "<tr><th bgcolor=\"yellow\">Réference</th><th bgcolor=\"yellow\">Catégorie</th><th
bgcolor=\"yellow\">Nom</th><th bgcolor=\"yellow\">Prix</th></tr>";
while($enreg=mysql_fetch_array($resultat)){
echo"<tr><td>".$enreg['ref']."</td><td>".$enreg['cat']."</td><td>".$enreg['nom']."</td><td>".$enreg['prix']."<
/td></tr>";
}
echo "</table>";
}
?>
</center>
</body>
</html>

Vous aimerez peut-être aussi