Rapport d'un site web dynamique

Preview:

DESCRIPTION

c'est un rapport de Tp "site web dynamique"

Citation preview

INSAT

RAPPORT DE TP

TELEMATIQUE Site Universitaire de L’INSAT

2008/2009

Réalisé par :

Salmen HITANA

Abdelkarim FITOURI

RT3/G1

RAPPORT DE TP TELEMATIQUE 2008/2009

2

Synoptique : Dans ce TP on a réalisé un site web d’une université.

Description de site : Ce site offre l'accès internet au étudient de l'université pour consulter leurs notes, dates des

examens et les livres disponibles dans la bibliothèque.

Composant du site :

Bases de données :

Projet : c’est la base de donnée principale elle contient toutes les informations sur les

étudient, les matières, les dates et les notes de tous les devoirs de chaque étudient et les livres

disponibles dans la bibliothèque.

Fichier_xml :c’est la base de données secondaire de ce site elle contient tous les noms des

fichiers XML générées par les recherches et les consultations de la base principal.

Conception : on a utilisé la méthode merise (MCD, MLD, MPD)

MCD (PROJET)

RAPPORT DE TP TELEMATIQUE 2008/2009

3

MLD(PROJET)

Devoir(id_dev,lib_dev) //Les différents types des devoirs(devoir surveillé, examen, TP)

Matiere(id_mat,nom_mat) //Les matières.

Etudient(id_etu,login_pass,nom_etu,pre_etu)//Informations sur les étudiants.

Livre(id_liv,nom_liv,code_liv,#id_cat)//Les livres.

Catégorie(id_cat,nom_cat)// les différents catégories des livres.

Dev_mat(#id_dev, #id_mat,date)//les dates des devoirs.

Etu_mat_dev(#id_etu, #id_mat, #id_dev,note)//les notes des étudiants .

Etu_liv(id_etu,id_liv)//Relation entre livre et étudient.

RAPPORT DE TP TELEMATIQUE 2008/2009

4

MPD(PROJET)

Pour l’autre base de donnée( fichier_xml) elle est constituée de trois table XML_livre, XML_note,

XML_date ; ces derniers ont la même structure (id_fich,nom_fich) .

Partie UML :

Taches assurées par le site de point du vue de l’étudient

Diagramme des cas d’utilisations

Déroulement de chaque tache Diagramme d’activité:

RAPPORT DE TP TELEMATIQUE 2008/2009

5

Authentification

Recherche

Notes

RAPPORT DE TP TELEMATIQUE 2008/2009

6

Dates des devoirs

Outil et langage utilisé :

Logiciels :

Bases des données :

On a utilisé « MySQL » pour la création et « phpMyAdmin » pour l’administration.

Pour la conception on a utilisé le logiciel libre « MySQL Workbench 5.0 OSS » (voir figure ‘MPD(PROJET)’).

« MySQL Workbench 5.0 OSS »

UML :

On a utilisé le logiciel libre « DIA » (voir les figures de parties UML)

RAPPORT DE TP TELEMATIQUE 2008/2009

7

« DIA »

Langages :

SQL pour les requêtes, php pour les pages (et bien sur aussi le html).

Description des différentes pages (site WEB) :

Les pages :

Index.php page ou l’utilisateur peut saisir son login et mot de passe. Envoi des données se

fait par la méthode POST à la page authentification_session.php

authentification_session.ph : Vérification des données en interrogeant la table des étudiants

si les données sont correct =>redirection automatique vers la page des choix si non vers la page

d’index

Tous les autres pages vérifient au début si l’utilisateur est connecté ou non si non redirection

automatique vers la page index.php

Le choix disponibles

�--- Les résultats sont affichés sur la page web avec la possibilité de consulter la version XML des

résultats----� Recherche des livres : L’utilisateur saisi le mot clé et choisie dans quel catégorie veut chercher (ou dans tous les

catégories)

RAPPORT DE TP TELEMATIQUE 2008/2009

8

Consultation des notes des devoirs :

L’utilisateur a le choix entre consultation des tous ses dans tous les matières ou d’une seule.

RAPPORT DE TP TELEMATIQUE 2008/2009

9

Consultation des dates des devoirs

L’utilisateur a le choix entre consultation des tous ses dans tous les matières ou d’une seule.

RAPPORT DE TP TELEMATIQUE 2008/2009

10

Historique des recherches :

Cette tache se fait en interrogeant la base des fichiers XML

RAPPORT DE TP TELEMATIQUE 2008/2009

11

Les prises écrans :

index.php page d'accueil

authentification_session.php pour l'authentification réussite

RAPPORT DE TP TELEMATIQUE 2008/2009

12

authentification_session.php pour l'authentification échouée

choix.php pour le menu

RAPPORT DE TP TELEMATIQUE 2008/2009

13

rech.php et recherche.php pour recherche des livres

RAPPORT DE TP TELEMATIQUE 2008/2009

14

date_pre.php et date.php pour les dates des examens

RAPPORT DE TP TELEMATIQUE 2008/2009

15

note_pre.php et note.php pour les notes des matières

RAPPORT DE TP TELEMATIQUE 2008/2009

16

Liste_xml.php consultation de tous les recherches faites

Accès a une page sont authentification

RAPPORT DE TP TELEMATIQUE 2008/2009

17

Les codes sources :

Index.php :

<?php // récuperation de session ouvert session_start(); // annulation de session $_SESSION = array(); session_destroy();

?> <html> <head> <title> Projet Télématique, Site univèrstaire(INSAT) </title>

</head> <body TEXT=#FFFFFF bgcolor="#000000"> <center>

<table border="4" width="700" bordercolor="#000000" background="insat.JPG"> <tr> <br>

<td bordercolor="#f9e56d"> <h2> <center> <Big> <tt> Projet télématique</big> <br> site univèrsitaire(INSAT)<br> <img src ="insat.PNG"> <br><SMALL> 2008/2009 </small>

</h2>

<center> <table border="2" width="30%" bordercolor="gray" bgcolor="#000000"> <tr> <td bordercolor="#f9e56d"> <center>

<form method="post" action="authentification_session.php" > <FONT color="#0099FF"><big>Connection</big> <p><FONT color="white"><strong>Pseudo</strong><br> <input name="pseudo" size="26" type="text">

<br><strong>Mot de passe</strong><br> <input name="password" size="26" type="password">

<p><input value="Réinitialiser" type="reset"> <input value="Connection" type="submit"> </form> </td> </tr>

</table> <br>

</td> </tr> </table> </body>

</html>

Authentification_session.php :

<?php //démarrer une session session_start();

$loginOK=false;?> <html> <head> </head>

<body TEXT=#000000 bgcolor="#000000">

RAPPORT DE TP TELEMATIQUE 2008/2009

18

<?php

//appel au fonctions.php (la fonction connexion()) require_once('fonction.php'); if ( isset($_POST) && (!empty($_POST['pseudo'])) && (!empty($_POST['password'])) ) {

extract($_POST); $pseudo = $_POST['pseudo'];

$password = $_POST['password']; if(connexion()) { //verification de login $req="select * from etudient where login='$pseudo'"; $resultat=mysql_query($req) or die("connexion impossible");

$num_row=mysql_num_rows($resultat); if( $num_row == 1 && !mysql_error())

{ $data = mysql_fetch_assoc($resultat); //verification de mot de passe if ($password == $data["pass"])

{ $loginOK = true; print "<br><br><br><br><center>"; print "<table border=\"2\" width=\"600\" bordercolor=\"gray\" background=\"OK.png\">";

print "<tr>"; print "<td bordercolor=\"#f9e56d\">";

print "<center>"; print "<center><h1><tt> <br><br><br>Vous êtes bien identifié"; print "<BR>"; echo "bonjour monsieur ";

echo $data["pre_etu"] ; print " "; echo $data["nom_etu"];

print "<BR>"; echo "Redirection vers page d'acceuil dans 2 seconde."; print "<BR>";

echo "appuyé <A HREF = \"choix.php\"> ici </A> pour continuer..."; print "<br><br><br><br><br> </h1>"; print "</form>";

print "</td>";

print "</tr>"; print "</table>";?> <meta http-equiv="refresh" content="3; URL=choix.php"> <? }

} } } if ($loginOK)

{ // si les données sont justes on recupère les information sur l'etudient tous le long de session $_SESSION['login'] = $data["login"];

$_SESSION['nom'] = $data["nom_etu"]; $_SESSION['pre'] = $data["pre_etu"]; $_SESSION['id'] = $data["id_etu"]; } else

{//les données incorrectes

RAPPORT DE TP TELEMATIQUE 2008/2009

19

echo 'Une erreur est survenue, veuillez réessayer !';

print "<br><br><br><br><center>"; print "<table border=\"2\" width=\"535\" bordercolor=\"gray\" background=\"stop-1.jpg\">"; print "<tr>"; print "<td bordercolor=\"#f9e56d\">";

print "<center>"; print "<center><h1><tt><br><br><br><br> Vérifier

votre demande"; print "<br><br><br><br> </h1>"; print "</form>"; print "</td>"; print "</tr>"; print "</table>";

?> </center><meta http-equiv="refresh" content="3; URL=index.php"><?

} ?> </Body> </html>

choix.php :

<?php session_start();?> <html> <head>

<title> projet télématique Site universitaire (INSAT) </tiltle> </head>

<body TEXT=#FFFFFF background="" bgcolor="#000000"> <br>

<?php if ( !isset($_SESSION) || (empty($_SESSION['nom'])) || (empty($_SESSION['pre'])) ) {?> <br><br><br><br><center> <table border="2" width="535" bordercolor="gray" background="stop-1.jpg"> <tr> <td bordercolor="#f9e56d" >

<center>

<h1><tt><br><br><br><br> Vous n'ètes pas connecter<br><br><br><br></h1></center> </td> </tr> </table> <meta http-equiv="refresh" content="3; URL=index.php"><?

} else { echo "<strong> "; echo "bonjour ";

echo $_SESSION['pre']; echo " ";

echo $_SESSION['nom'];print " nous sommes le :"; echo date ("d/m/Y"); print "<BR>"; print "il est :"; echo date ("H:i:s");

print "<P>" ; echo "</strong>";

?> <center> <table border="4" width="700" height="500" bordercolor="#000000" background="insat.JPG" TEXT=#FFFFFF>

<tr> <td bordercolor="#f9e56d" >

RAPPORT DE TP TELEMATIQUE 2008/2009

20

<h2>

<center> <Big> <tt> Projet télématique </tt></big> <br> site universitaire (INSAT)<br> <img src ="insat.PNG">

<br><SMALL> 2008/2009 </small> </center>

</h2> <center> <table border="2" width="30%" bordercolor="gray" bgcolor="gray"> <tr> <center> <td bordercolor="#f9e56d">

<center> BIENVENUE...</center> </td>

</center> </tr> </table> </center>

<center> <p><A HREF="rech.php"><input value="chercher un livre" type="submit"></A><br> <p><A HREF="date_pre.php"><input value="dates des examens" type="submit"></A><br> <p><A HREF="note_pre.php"><input value="notes des examens" type="submit"></A> <p><A HREF="liste_xml.php"><input value="ancient recherche" type="submit"></A><br>

<p><A HREF = "index.php"><input value="deconnecter" type="submit"></A> </td>

</tr> </table> <? }?> </body> </html>

Liste_xml.php:

<?php session_start();?> <html>

<head>

</head> <BODY TEXT=#000000 bgcolor="#FFFFFF"> <?php if ( !isset($_SESSION) || (empty($_SESSION['nom'])) || (empty($_SESSION['pre'])) ) {?> <br><br><br><br><center>

<table border="2" width="535" bordercolor="gray" background="stop-1.jpg"> <tr> <td bordercolor="#f9e56d" > <center> <h1><tt><br><br><br><br> Vous n'ètes pas connecter<br><br><br><br></h1></center>

</td> </tr>

</table> <meta http-equiv="refresh" content="3; URL=index.php"><? } else {

echo "<strong> "; echo "bonjour ";

echo $_SESSION['pre']; echo " "; echo $_SESSION['nom'];print " nous sommes le :"; echo date ("d/m/Y");

$date_act = date ("d-m-Y"); print "<BR>";

RAPPORT DE TP TELEMATIQUE 2008/2009

21

print "il est :";

echo date ("H:i:s"); $heure_act = date ("H-i-s"); print "<P>" ; echo "</strong>";

$mon_id=$_SESSION['id']; $mon_nom=$_SESSION['nom'];

$mon_pre=$_SESSION['pre']; $link_bd_xml=mysql_connect("localhost","root","") or die("connexion impossible"); mysql_select_db('fichier_xml') or die("access à la BD impossible"); $req_xml1="SELECT * FROM xml_note"; $resultat_xml1=mysql_query($req_xml1) or die("verifier la requete req_xml1");

echo "<BR><strong>LES NOTES</strong>"; while($row_xml1=mysql_fetch_array($resultat_xml1))

{ echo "<p>"; $lien = $row_xml1["nom_fich"]; echo "<A HREF = \"$lien\"> $lien</A></p>";

} echo "<BR><strong>LES DATES</strong>"; $req_xml1="SELECT * FROM xml_date"; $resultat_xml1=mysql_query($req_xml1) or die("verifier la requete req_xml1"); while($row_xml1=mysql_fetch_array($resultat_xml1))

{ echo "<p>";

$lien = $row_xml1["nom_fich"]; echo "<A HREF = \"$lien\"> $lien</A></p>"; } echo "<BR><strong>LES LIVRES</strong>"; $req_xml1="SELECT * FROM xml_livre";

$resultat_xml1=mysql_query($req_xml1) or die("verifier la requete req_xml1"); while($row_xml1=mysql_fetch_array($resultat_xml1)) {

echo "<p>"; $lien = $row_xml1["nom_fich"]; echo "<A HREF = \"$lien\"> $lien</A></p>"; }

}?>

date_pre.php:

<?php session_start();?>

<html> <head> <title>projet télématique Site universitaire (INSAT) </tiltle>

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

body { background-color: #000000; } --> </style></head>

<body TEXT=#FFFFFF> <br>

<?php //si l'utilisateur est authentifié ou pas if ( !isset($_SESSION) || (empty($_SESSION['nom'])) || (empty($_SESSION['pre'])) ) {?> <br><br><br><br><center>

<table border="2" width="535" bordercolor="gray" background="stop-1.jpg"> <tr>

RAPPORT DE TP TELEMATIQUE 2008/2009

22

<td bordercolor="#f9e56d" >

<center> <h1><tt><br><br><br><br> Vous n'ètes pas connecter<br><br><br><br></h1></center> </td> </tr>

</table> <meta http-equiv="refresh" content="3; URL=index.php"><?

} else { echo "<strong> "; echo "bonjour "; echo $_SESSION['pre'];

echo " "; echo $_SESSION['nom'];print " nous sommes le :";

echo date ("d/m/Y"); print "<BR>"; print "il est :"; echo date ("H:i:s");

print "<P>" ; echo "</strong>"; ?> <center> <table border="4" width="700" height="500" bordercolor="#000000" background="insat.JPG">

<tr> <td bordercolor="#f9e56d">

<h2> <center> <Big> <tt>DATE DES DEVOIRS</tt></big> <br> site universitaire (INSAT)<br> <img src ="insat.PNG"> <br><SMALL> 2008/2009 </small>

</h2> </center> <center>

<table border="2" width="30%" bordercolor="gray" bgcolor="gray"> <tr> <center> <td bordercolor="#f9e56d">

<strong><center> Dates des examens... </center></strong> </td> </center> </tr> </table>

<br>

<center> <table border="2" width="30%" bordercolor="gray" bgcolor="#000000"> <tr> <td bordercolor="#f9e56d"> <center>

<form method="get" action="date_bd_xml.php" > <FONT color="#0000CD"><strong>matière</strong><br> <? // liste des matiere require_once('fonction.php');

connexion(); //charger tous les matieres pour les metres dans une liste $query="select * from matiere";

$result=mysql_query($query) or die("la requéte a echoué"); $i=0; echo "<p><FONT color=\"white\"><strong>Matiere</strong><br>"; echo "<select name=\"matiere\">";

echo ("<option selected value=-1>tous les matières</option>");

RAPPORT DE TP TELEMATIQUE 2008/2009

23

while($row=mysql_fetch_array($result))

{ $tab_id_mat =$row["id_mat"]; $tab_nom_mat =$row["lib_mat"]; echo ("<option

value=\"$tab_nom_mat\">$tab_nom_mat</option>"); }

echo "</select>"; ?> <p><input value="Réinitialiser" type="reset"> <input value="consulter" type="submit"> </form> </td>

</tr> <tr>

<td bordercolor="#f9e56d"> <center><A HREF = "choix.php"><input value="HOME" type="submit"></A><Br> <A HREF = "index.php"><input value="deconnecter" type="submit"></A></center> </td>

</tr> </table> </center> <? }?> </body></html>

note_pre.php: <?php session_start();?> <html>

<head> <title>projet télématique Site universitaire (INSAT) </tiltle> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"> <!--

body { background-color: #000000; } -->

</style></head> <body TEXT=#FFFFFF>

<br> <?php if ( !isset($_SESSION) || (empty($_SESSION['nom'])) || (empty($_SESSION['pre'])) ) {?> <br><br><br><br><center> <table border="2" width="535" bordercolor="gray" background="stop-1.jpg"> <tr>

<td bordercolor="#f9e56d" >

<center> <h1><tt><br><br><br><br> Vous n'ètes pas connecter<br><br><br><br></h1></center> </td> </tr> </table>

<meta http-equiv="refresh" content="3; URL=index.php"><? } else { echo "<strong> ";

echo "bonjour "; echo $_SESSION['pre'];

echo " "; echo $_SESSION['nom'];print " nous sommes le :"; echo date ("d/m/Y");

RAPPORT DE TP TELEMATIQUE 2008/2009

24

print "<BR>";

print "il est :"; echo date ("H:i:s"); print "<P>" ; echo "</strong>";

?> <center>

<table border="4" width="700" height="500" bordercolor="#000000" background="insat.JPG"> <tr> <td bordercolor="#f9e56d"> <h2> <center> <Big> <tt> NOTES DES DEVOIRS</tt></big> <br> site universitaire (INSAT)<br>

<img src ="insat.PNG"> <br><SMALL> 2008/2009 </small>

</h2> </center> <center> <table border="2" width="30%" bordercolor="gray" bgcolor="gray">

<tr> <center> <td bordercolor="#f9e56d"> <strong><center> Notes des examens... </center></strong> </td>

</center> </tr>

</table> <br> <center> <table border="2" width="30%" bordercolor="gray" bgcolor="#000000"> <tr>

<td bordercolor="#f9e56d"> <center> <form method="get" action="note_bd_xml.php" >

<FONT color="#0000CD"><strong>matière</strong><br> <? // liste des matiere require_once('fonction.php'); connexion();

//charger tous les matieres pour les metres dans une liste $query="select * from matiere"; $result=mysql_query($query) or die("la requéte a echoué"); $i=0; echo "<p><FONT

color=\"white\"><strong>Matiere</strong><br>";

echo "<select name=\"matiere\">"; echo ("<option selected value=-1>tous les matières</option>"); while($row=mysql_fetch_array($result)) { $tab_id_mat =$row["id_mat"];

$tab_nom_mat =$row["lib_mat"]; echo ("<option value=\"$tab_id_mat\">$tab_nom_mat</option>"); }

echo "</select>"; ?> <p><input value="Consulter" type="submit">

<p><input value="Réinitialiser" type="reset"> </form> </td> </tr> <tr>

<td bordercolor="#f9e56d">

RAPPORT DE TP TELEMATIQUE 2008/2009

25

<center><A HREF = "choix.php"><input value="HOME" type="submit"></A><Br>

<A HREF = "index.php"><input value="deconnecter" type="submit"></A></center> </td> </tr> </table>

</center> <? }?>

</body> </html>

rech_pre.php:

<?php session_start();?>

<html> <head>

<title> Recherche

</title>

</head> <body TEXT=#FFFFFF bgcolor="#000000"> <?php if ( !isset($_SESSION) || (empty($_SESSION['nom'])) || (empty($_SESSION['pre'])) )

{?>

<br><br><br><br><center> <table border="2" width="535" bordercolor="gray" background="stop-1.jpg"> <tr>

<td bordercolor="#f9e56d" >

<center> <h1><tt><br><br><br><br> Vous n'ètes pas connecter<br><br><br><br></h1></center>

</td> </tr>

</table> <meta http-equiv="refresh" content="3; URL=index.php"><?

}

else {

echo "<strong> "; echo "bonjour ";

echo $_SESSION['pre'];

echo " "; echo $_SESSION['nom'];print " nous sommes le :"; echo date ("d/m/Y");

print "<BR>";

print "il est :";

echo date ("H:i:s"); print "<P>" ;

echo "</strong>";

?>

<center> <table border="4" width="700" bordercolor="#000000" background="insat.JPG"> <tr>

<br>

<td bordercolor="#f9e56d"> <h2>

<center> <Big> <tt> RECHERCHE DES LIVRES</big> <br> site univèrsitaire(INSAT)<br>

RAPPORT DE TP TELEMATIQUE 2008/2009

26

<img src ="insat.PNG">

</h2>

<center> <table border="2" width="30%" bordercolor="gray" bgcolor="#000000">

<tr> <td bordercolor="#f9e56d">

<center>

<form method="GET" action="recherche_bd_xml.php" > <FONT color="#0099FF"> <big>RECHERCHE</big>

<p><FONT color="white"><strong>Mot Clé</strong><br>

<input name="mot_cle" size="26" type="text">

<?php require_once('fonction.php');

if(connexion())

{

//charger tous les catégories pour les mettres dans une liste $query="select * from categorie";

$result=mysql_query($query) or die("la

requéte a echoué"); $i=0;

echo "<p><FONT color=\"white\"><strong>Catégorie</strong><br>";

echo "<select name=\"cat\">"; echo ("<option selected value=-1>tous les

catégories</option>"); while($row=mysql_fetch_array($result))

{ $tab_id_cat =$row["id_cat"];

$tab_nom_cat =$row["nom_cat"];

echo ("<option value=\"$tab_id_cat\">$tab_nom_cat</option>");

} echo "</select>";

}else

{ echo "<BR>"; echo "base de donnée indisponible";

}

?>

<p><input value="Réinitialiser" type="reset"> <input value="Rechercher" type="submit">

</form>

</td>

</tr> <tr> <td bordercolor="#f9e56d"><center>

<p><A HREF = "choix.php"><input value="HOME" type="submit"></A>

<p><A HREF = "index.php"><input value="deconnecter" type="submit"></A> </p></p></center>

RAPPORT DE TP TELEMATIQUE 2008/2009

27

</td>

</tr>

</table> <br>

</td> </tr>

</table>

<? } ?> </body> </html>

date_bd_xml.php: <?php session_start();?>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title></title>

<style type="text/css">

<!--

.style1 {color: #993300}

-->

</style>

</head>

<body>

<?php if ( !isset($_SESSION) || (empty($_SESSION['nom'])) || (empty($_SESSION['pre'])) )

{?>

<br><br><br><br><center>

<table border="2" width="535" bordercolor="gray" background="stop-1.jpg">

<tr>

<td bordercolor="#f9e56d" >

<center>

<h1><tt><br><br><br><br> Vous n'ètes pas connecter<br><br><br><br></h1></center>

</td>

</tr>

</table>

<meta http-equiv="refresh" content="3; URL=index.php"><?

}

else

{

echo "<strong> ";

echo "bonjour ";

echo $_SESSION['pre'];

echo " ";

echo $_SESSION['nom'];print " nous sommes le :";

echo date ("d/m/Y");

$date_act = date ("d-m-Y");

print "<BR>";

print "il est :";

echo date ("H:i:s");

$heure_act = date ("H-i-s");

print "<P>" ;

echo "</strong>";

$mon_id=$_SESSION['id'];

$mon_nom=$_SESSION['nom'];

$mon_pre=$_SESSION['pre'];

RAPPORT DE TP TELEMATIQUE 2008/2009

28

$matiere= $_GET['matiere'];

require_once('fonction.php');

if($matiere!=-1)

{

$req="select * from matiere where (lib_mat='$matiere')";

$f = "date des devoirs de ".$matiere."2.xml";

$f = "date_devoir_".$matiere."_".$date_act."_".$heure_act.".xml";

}

else

{

$req="select * from matiere";

$f = "date_tous_devoirs_".$date_act."_".$heure_act.".xml";

}

//sauvegarde de fichiers XML dans la base XML_fichier

$link_bd_xml=mysql_connect("localhost","root","")/* or die("connexion impossible")*/;

if($link_bd_xml== false)

{echo mysql_errno($link) . ": " . mysql_error($link) . "\n";exit;}

mysql_select_db('fichier_xml') or die("access à la BD impossible");

$req_xml1="SELECT id_fich FROM xml_date ORDER BY id_fich DESC";

$id_xml = 0;

$resultat_xml1=mysql_query($req_xml1) or die("verifier la requete req_xml1");

$row_xml1=mysql_fetch_array($resultat_xml1);

if($row_xml1 != 0)

$id_xml = $row_xml1["id_fich"] + 1;

$req_xml2="INSERT INTO `xml_date` (`id_fich`, `nom_fich`) VALUES (\"$id_xml\", \"$f\")";

$resultat_xml2=mysql_query($req_xml2) or die("verifier la requete req_xml2");

connexion();

$resultat=mysql_query($req) or die("connexion impossible");

$num_row=mysql_num_rows($resultat);

if( $num_row >= 1 && !mysql_error())

{//creation de fichier xml

$file=fopen($f,'w');

fwrite($file,"<?xml version=\"1.0\" encoding=\"utf-8\" ?><?xml-stylesheet type=\"text/xsl\"

href=\"date_devoir2.xsl\"?><projet>");

print "<BR><center><img src=\"INSAT.png\"></center><br><center><table border=\"4\"

width=\"600\" height=\"300\" bordercolor=\"black\" ><body bgcolor=' lightgrey'><tr><td><font size=\"4\"

face=\"Georgia, Times New Roman, Times, serif\" color=\"darkslategray\"><i><center>";

while($row=mysql_fetch_array($resultat))

{

$a=$row["id_mat"];

$nom_mat=$row["lib_mat"];

$req2="select date,id_dev from dev_mat where (id_mat='$a')";

$resultat2=mysql_query($req2) or die("connexion impossible");

$num_row2=mysql_num_rows($resultat2);

if( $num_row2 == 0)//si la date de matière n'est pas encore saisie

{

echo"<br>";echo"<br>";

print"<strong>";

echo "<u><span class=\"style1\">nous sommes désolé mais nous n'avons pas Les

dates des examens pour la matière $nom_mat :</span></u>";

echo"<br>";

}

else //traitement des donnée

RAPPORT DE TP TELEMATIQUE 2008/2009

29

{

//HTML

echo "Bonjour .. <br>Voici le résultat de votre consultation

:</i></font><br><br><strong>";

echo" <u><span class=\"style1\">Les dates des examens pour la matière $nom_mat

:</span></u> ";

print"<br><br>";

fwrite($file,"<M>");

while($row2=mysql_fetch_array($resultat2))

{

if($row2["id_dev"]=='1')

$b="examen";

if($row2["id_dev"]=='0')

$b="devoir surveillée";

if($row2["id_dev"]=='2')

$b="TP";

echo $b;

echo" : ";

echo $row2["date"];

print"<br>";

$date = $row2["date"];

//fichier xml

fwrite($file,"<date_matiere>");

fwrite($file,"<matiere>");fwrite($file,"$nom_mat");fwrite($file,"</matiere>");

fwrite($file,"<exam>");fwrite($file,"$b");fwrite($file,"</exam>");

fwrite($file,"<date>");fwrite($file,"$date");fwrite($file,"</date>");

fwrite($file,"</date_matiere>");

}

fwrite($file,"</M>");

}

}

fwrite($file,"</projet>");

fclose($file);

print"<p><A HREF=\"$f\"><input value=\"Version XML\" type=\"submit\"></A>";

}

else //pour les req erronés

{

echo "<body bgcolor=' lightgrey'>";

print "<center>";

print "<table border=\"2\" width=\"535\" height=\"307\" bordercolor=\"gray\"

background=\"stop.jpg\">";

print "<tr>";

print "<td bordercolor=\"#f9e56d\">";

print "<center>";

print "<center><h1><tt><br><br><br> Vérifier votre requète";

print "<br><br><br></h1>";

print "</form>";

print "</td>";

print "</tr>";

print "</table>";

print "<table><tr><td>";

}

//pour les boutons

RAPPORT DE TP TELEMATIQUE 2008/2009

30

echo "<center>";

print"<p><A HREF=\"index.php\"><input value=\"deconnecter\" type=\"submit\"></A>";

print"<A HREF=\"date_pre.php\"><input value=\"date devoir\" type=\"submit\"></A>";

print"<A HREF=\"choix.php\"><input value=\"HOME\" type=\"submit\"></A>";

echo "</center>";

print"</strong></td></tr></center></table>";

}

?>

</body>

</html>

note_bd_xml.php : <?php session_start();?>

<html>

<head>

</head>

<BODY TEXT=#FFFFFF bgcolor="#000000">

<?php if ( !isset($_SESSION) || (empty($_SESSION['nom'])) || (empty($_SESSION['pre'])) )

{?>

<br><br><br><br><center>

<table border="2" width="535" bordercolor="gray" background="stop-1.jpg">

<tr>

<td bordercolor="#f9e56d" >

<center>

<h1><tt><br><br><br><br> Vous n'ètes pas connecter<br><br><br><br></h1></center>

</td>

</tr>

</table>

<meta http-equiv="refresh" content="3; URL=index.php"><?

}

else

{

//$id_etu = $_SESSION['id'];

echo "<strong> ";

echo "bonjour ";

echo $_SESSION['pre'];

echo " ";

echo $_SESSION['nom'];print " nous sommes le :";

echo date ("d/m/Y");

$date_act = date ("d-m-Y");

print "<BR>";

print "il est :";

echo date ("H:i:s");

$heure_act = date ("H-i-s");

print "<P>" ;

echo "</strong>";

$mon_id=$_SESSION['id'];

$mon_nom=$_SESSION['nom'];

$mon_pre=$_SESSION['pre'];

?>

<center>

<table border="4" width="700" bordercolor="#000000" background="insat.JPG">

<tr>

<br>

RAPPORT DE TP TELEMATIQUE 2008/2009

31

<td bordercolor="#f9e56d">

<h2>

<center> <Big> <tt>NOTES DES DEVOIRS</big>

<br> site univ&egrave;rsitaire(INSAT)<br>

<img src ="insat.PNG">

<br><SMALL> 2008/2009 </small>

</h2>

<center>

<table border="2" width="30%" bordercolor="gray" bgcolor="#000000">

<?php

require_once('fonction.php');

if(connexion())

{}

else

{

echo "";

exit;

}

echo "<tr>";

echo "<td bordercolor=\"#f9e56d\">";

$id_mat=$_GET['matiere'];

if($id_mat!=-1)

{

$req="select note,id_dev from note where id_etu = $mon_id and id_mat =

$id_mat";

$req2="select * from matiere where id_mat = $id_mat";

$resultat=mysql_query($req) or die("verifier la requete req");

$num_row=mysql_num_rows($resultat);

$resultat2=mysql_query($req2) or die("verifier la requete req2");

$row2=mysql_fetch_array($resultat2);

$mat=$row2["lib_mat"];

$f =

"notes_".$mon_pre."_".$mon_nom."_".$mat."_".$date_act."_".$heure_act.".xml";

//sauvegarde de fichiers

$link_bd_xml=mysql_connect("localhost","root","") or die("connexion

impossible");

mysql_select_db('fichier_xml') or die("access à la BD impossible");

$req_xml1="SELECT id_fich FROM xml_note ORDER BY id_fich DESC";

$id_xml = 0;

$resultat_xml1=mysql_query($req_xml1) or die("verifier la requete

req_xml1");

$row_xml1=mysql_fetch_array($resultat_xml1);

if($row_xml1 != 0)

$id_xml = $row_xml1["id_fich"] + 1;

$req_xml2="INSERT INTO `xml_note` (`id_fich`, `nom_fich`) VALUES

(\"$id_xml\", \"$f\")";

$resultat_xml2=mysql_query($req_xml2) or die("verifier la requete

req_xml2");

if($num_row>=1 && !mysql_error())

{

$file=fopen($f,'w');

fwrite($file,"<?xml version=\"1.0\" encoding=\"utf-8\" ?><?xml-

stylesheet type=\"text/xsl\" href=\"note_devoir.xsl\"?><projet>");

RAPPORT DE TP TELEMATIQUE 2008/2009

32

fwrite($file,"<M>");

echo "<u><strong><br>Vos notes de la matiere ";

echo $row2["lib_mat"];

echo "</strong></u>";

while($row=mysql_fetch_array($resultat))

{

if($row["id_dev"]=='1')

$b="examen";

if($row["id_dev"]=='0')

$b="devoir surveillé";

if($row["id_dev"]=='2')

$b="TP";

echo "<center><br>";

echo $b;

echo "<strong> ";echo $row["note"]; echo

"</strong></center>";

$note = $row["note"];

fwrite($file,"<note_matiere>");

fwrite($file,"<matiere>");fwrite($file,"$mat");fwrite($file,"</matiere>");

fwrite($file,"<exam>");fwrite($file,"$b");fwrite($file,"</exam>");fwrite($file,"<note>");

fwrite($file,"$note");fwrite($file,"</note>");fwrite($file,"</note_matiere>");

}

fwrite($file,"</M>");

fwrite($file,"</projet>");

fclose($file);

print"<p><A HREF=\"$f\"><input value=\"Version XML\"

type=\"submit\"></A>";

}

else

{

echo "<BR>les devoirs de cette matiere ne sont pas corrigées";

}

}

else

{

$req2="select * from matiere";

$resultat2=mysql_query($req2) or die("verifier la requete");

$f =

"notes_".$mon_pre."_".$mon_nom."_".$date_act."_".$heure_act.".xml";

//sauvegarde de fichiers

$link_bd_xml=mysql_connect("localhost","root","") or die("connexion

impossible");

mysql_select_db('fichier_xml') or die("access à la BD impossible");

$req_xml1="SELECT id_fich FROM xml_note ORDER BY id_fich DESC";

$id_xml = 0;

$resultat_xml1=mysql_query($req_xml1) or die("verifier la requete

req_xml1");

$row_xml1=mysql_fetch_array($resultat_xml1);

if($row_xml1 != 0)

$id_xml = $row_xml1["id_fich"] + 1;

RAPPORT DE TP TELEMATIQUE 2008/2009

33

$req_xml2="INSERT INTO `xml_note` (`id_fich`, `nom_fich`) VALUES

(\"$id_xml\", \"$f\")";

$resultat_xml2=mysql_query($req_xml2) or die("verifier la requete

req_xml2");

$file=fopen($f,'w');

fwrite($file,"<?xml version=\"1.0\" encoding=\"utf-8\" ?><?xml-stylesheet

type=\"text/xsl\" href=\"note_devoir.xsl\"?><projet>");

connexion();

while($row2=mysql_fetch_array($resultat2))

{

$mat=$row2["lib_mat"];

$id_matiere=$row2["id_mat"];

$req="select note,id_dev from note where id_etu = '$mon_id'

and id_mat = $id_matiere";

$resultat=mysql_query($req) or die("verifier la requete");

$num_row=mysql_num_rows($resultat);

echo "<br>";

//echo $req;

//echo $req2;

if($num_row>=1 && !mysql_error())

{

echo "<u><strong><br>Vos notes de la matiere ";

echo $row2["lib_mat"];

echo "</strong></u>";

fwrite($file,"<M>");

while($row=mysql_fetch_array($resultat))

{

if($row["id_dev"]=='1')

$b="examen";

if($row["id_dev"]=='0')

$b="devoir surveillé";

if($row["id_dev"]=='2')

$b="TP";

echo "<center><br>";

echo $b;

echo "<strong> ";echo $row["note"]; echo

"</strong></center>";

$note = $row["note"];

fwrite($file,"<note_matiere>");

fwrite($file,"<matiere>");fwrite($file,"$mat");fwrite($file,"</matiere>");

fwrite($file,"<exam>");fwrite($file,"$b");fwrite($file,"</exam>");

fwrite($file,"<note>");fwrite($file,"$note");fwrite($file,"</note>");

fwrite($file,"</note_matiere>");

}

fwrite($file,"</M>");

}

else

{

echo "<BR>";

print "les devoirs de <u><strong>";

echo $mat;

RAPPORT DE TP TELEMATIQUE 2008/2009

34

echo "</u></strong> ne sont pas corrigées";

}

}

fwrite($file,"</projet>");

fclose($file);

print"<center><p><A HREF=\"$f\"><input value=\"Version XML\"

type=\"submit\"></A></center>";

}

echo "</td></tr><br>";

?>

</center>

<tr>

<td bordercolor="#f9e56d">

<center><p><A HREF = "note_pre.php"><input value="notes" type="submit"></A></p>

<p><A HREF = "choix.php"><input value="HOME" type="submit"></A></p>

<p><A HREF = "index.php"><input value="deconnecter" type="submit"></A></p></center>

</td>

</tr>

</table>

<br>

</td>

</tr>

</table>

<? } ?>

</center>

</Body>

</html>

recherche_bd_xml.php : <?php session_start();?>

<html>

<head>

</head>

<BODY TEXT=#FFFFFF bgcolor="#000000">

<?php if ( !isset($_SESSION) || (empty($_SESSION['nom'])) || (empty($_SESSION['pre'])) )

{?>

<br><br><br><br><center>

<table border="2" width="535" bordercolor="gray" background="stop-1.jpg">

<tr>

<td bordercolor="#f9e56d" >

<center>

<h1><tt><br><br><br><br> Vous n'ètes pas connecter<br><br><br><br></h1></center>

</td>

</tr>

</table>

<meta http-equiv="refresh" content="3; URL=index.php"><?

}

else

{

echo "<strong> ";

echo "bonjour ";

echo $_SESSION['pre'];

echo " ";

echo $_SESSION['nom'];print " nous sommes le :";

RAPPORT DE TP TELEMATIQUE 2008/2009

35

echo date ("d/m/Y");

$date_act = date ("d-m-Y");

print "<BR>";

print "il est :";

echo date ("H:i:s");

$heure_act = date ("H-i-s");

print "<P>" ;

echo "</strong>";

$mon_id=$_SESSION['id'];

$mon_nom=$_SESSION['nom'];

$mon_pre=$_SESSION['pre'];

?>

<center>

<table border="4" width="700" bordercolor="#000000" background="insat.JPG">

<tr>

<br>

<td bordercolor="#f9e56d">

<h2>

<center> <Big> <tt>RECHERCHE DES LIVRES</big>

<br> site univ&egrave;rsitaire(INSAT)<br>

<img src ="insat.PNG">

<br><SMALL> 2008/2009 </small>

</h2>

<center>

<table border="2" width="30%" bordercolor="gray" bgcolor="#000000">

<?php

require_once('fonction.php');

if(connexion())

{}

else

{

echo "";

exit;

}

echo "<tr><td bordercolor=\"#f9e56d\">";

if($_GET['mot_cle']!="" and $_GET['cat']!= "-1")

{ //si les deux champs sont remplies

$mot_cle = $_GET['mot_cle'];

$cat = $_GET['cat'];

$req="select nom_liv from livre where livre.nom_liv LIKE '%$mot_cle%' and

livre.id_cat = $cat";

$resultat=mysql_query($req) or die("verifier la requete");

$num_row=mysql_num_rows($resultat);

$req1="select nom_cat from categorie where categorie.id_cat = $cat";

$resultat1=mysql_query($req1) or die("verifier la requete");

$row1=mysql_fetch_array($resultat1);

echo "<strong >Recherche de '$mot_cle' dans '";

echo $row1["nom_cat"];

echo "'</strong>";

echo "<BR>";

if( $num_row >0 && !mysql_error())

{

$f =

"rech_'".$mot_cle."'_".$row1["nom_cat"]."_".$date_act."_".$heure_act.".xml";

RAPPORT DE TP TELEMATIQUE 2008/2009

36

$link_bd_xml=mysql_connect("localhost","root","") or

die("connexion impossible");

mysql_select_db('fichier_xml') or die("access à la BD

impossible");

$req_xml1="SELECT id_fich FROM xml_livre ORDER BY id_fich

DESC";

$id_xml = 0;

$resultat_xml1=mysql_query($req_xml1) or die("verifier la

requete req_xml1");

$row_xml1=mysql_fetch_array($resultat_xml1);

if($row_xml1 != 0)

$id_xml = $row_xml1["id_fich"] + 1;

$req_xml2="INSERT INTO `xml_livre` (`id_fich`, `nom_fich`)

VALUES (\"$id_xml\", \"$f\")";

$resultat_xml2=mysql_query($req_xml2) or die("verifier la

requete req_xml2");

mysql_close($link_bd_xml);

$file=fopen($f,'w');

fwrite($file,"<?xml version=\"1.0\" encoding=\"utf-8\" ?><?xml-

stylesheet type=\"text/xsl\" href=\"cat_mot.xsl\"?><projet>");

echo "<center>";

while($row=mysql_fetch_array($resultat)){

echo $row["nom_liv"];

$nom_liv = $row["nom_liv"];

echo "<BR>";

fwrite($file,"<livre>");

fwrite($file,"<nom_livre>");fwrite($file,"$nom_liv");fwrite($file,"</nom_livre>");

fwrite($file,"</livre>");

}

fwrite($file,"</projet>");

fclose($file);

print"<p><A HREF=\"$f\"><input value=\"Version XML\"

type=\"submit\"></A>";

echo "</center>";

}

else

{

echo "<BR>";

print "aucun resultat1";

}

}

else

{

if($_GET['cat']=="-1" and $_GET['mot_cle']=="")

{//si seulement le champs catégorie est remplie

$req="select nom_liv from livre";

$resultat=mysql_query($req) or die("verifier la requet");

$num_row=mysql_num_rows($resultat);

echo "<strong >Recherche dans tous les

catégories</strong><BR><center>";

if( $num_row >0 && !mysql_error())

RAPPORT DE TP TELEMATIQUE 2008/2009

37

{

$f = "rech_tous_".$date_act."_".$heure_act.".xml";

$link_bd_xml=mysql_connect("localhost","root","") or

die("connexion impossible");

mysql_select_db('fichier_xml') or die("access à la BD

impossible");

$req_xml1="SELECT id_fich FROM xml_livre ORDER BY

id_fich DESC";

$id_xml = 0;

$resultat_xml1=mysql_query($req_xml1) or

die("verifier la requete req_xml1");

$row_xml1=mysql_fetch_array($resultat_xml1);

if($row_xml1 != 0)

$id_xml = $row_xml1["id_fich"] + 1;

$req_xml2="INSERT INTO `xml_livre` (`id_fich`,

`nom_fich`) VALUES (\"$id_xml\", \"$f\")";

$resultat_xml2=mysql_query($req_xml2) or

die("verifier la requete req_xml2");

mysql_close($link_bd_xml);

$file=fopen($f,'w');

fwrite($file,"<?xml version=\"1.0\" encoding=\"utf-8\"

?><?xml-stylesheet type=\"text/xsl\" href=\"cat_mot.xsl\"?><projet>");

while($row=mysql_fetch_array($resultat))

{

$nom_liv=$row["nom_liv"];

fwrite($file,"<livre>");

fwrite($file,"<nom_livre>");fwrite($file,"$nom_liv");fwrite($file,"</nom_livre>");

fwrite($file,"</livre>");

echo $row["nom_liv"];

echo "<BR>";

}

fwrite($file,"</projet>");

fclose($file);

print"<p><A HREF=\"$f\"><input value=\"Version

XML\" type=\"submit\"></A>";

echo "<center>";

}

else{

echo "<BR>";

print "aucun resultat";

}

}

else

{

if($_GET['cat']=="-1" and $_GET['mot_cle']!="")

{

$mot_cle = $_GET['mot_cle'];

$req="select nom_liv from livre where livre.nom_liv

LIKE '%$mot_cle%'";

$resultat=mysql_query($req) or die("verifier la reque");

$num_row=mysql_num_rows($resultat);

RAPPORT DE TP TELEMATIQUE 2008/2009

38

if( $num_row >0 && !mysql_error()){

$f =

"rech_'".$mot_cle."'_".$date_act."_".$heure_act.".xml";

$link_bd_xml=mysql_connect("localhost","root","") or die("connexion impossible");

mysql_select_db('fichier_xml') or die("access

à la BD impossible");

$req_xml1="SELECT id_fich FROM xml_livre

ORDER BY id_fich DESC";

$id_xml = 0;

$resultat_xml1=mysql_query($req_xml1) or

die("verifier la requete req_xml1");

$row_xml1=mysql_fetch_array($resultat_xml1);

if($row_xml1 != 0)

$id_xml = $row_xml1["id_fich"] + 1;

$req_xml2="INSERT INTO `xml_livre`

(`id_fich`, `nom_fich`) VALUES (\"$id_xml\", \"$f\")";

$resultat_xml2=mysql_query($req_xml2) or

die("verifier la requete req_xml2");

mysql_close($link_bd_xml);

$file=fopen($f,'w');

fwrite($file,"<?xml version=\"1.0\"

encoding=\"utf-8\" ?><?xml-stylesheet type=\"text/xsl\" href=\"cat_mot.xsl\"?><projet>");

echo "<strong>Recherche de

'$mot_cle'</strong>";

echo "<center>";

while($row=mysql_fetch_array($resultat)){

$nom_liv=$row["nom_liv"];

fwrite($file,"<livre>");

fwrite($file,"<nom_livre>");fwrite($file,"$nom_liv");fwrite($file,"</nom_livre>");

fwrite($file,"</livre>");

echo $row["nom_liv"];

echo "<BR>";

}

echo "</center>";

fwrite($file,"</projet>");

fclose($file);

print"<p><A HREF=\"$f\"><input

value=\"Version XML\" type=\"submit\"></A>";

}

else{

echo "<BR>";

print "aucun resultat3";

}

}

else

{

$cat = $_GET['cat'];

RAPPORT DE TP TELEMATIQUE 2008/2009

39

$req="select nom_liv from livre where livre.id_cat =

'$cat'";

$resultat=mysql_query($req) or die("verifier la reque");

$num_row=mysql_num_rows($resultat);

$req1="select nom_cat from categorie where

categorie.id_cat = $cat";

$resultat1=mysql_query($req1) or die("verifier la

requete");

$row1=mysql_fetch_array($resultat1);

echo "<strong >Recherche dans '";

echo $row1["nom_cat"];

echo "'</strong>";

echo "<BR>";

$f =

"rech_tous_".$row1["nom_cat"]."_".$date_act."_".$heure_act.".xml";

$link_bd_xml=mysql_connect("localhost","root","") or

die("connexion impossible");

mysql_select_db('fichier_xml') or die("access à la BD

impossible");

$req_xml1="SELECT id_fich FROM xml_livre ORDER BY

id_fich DESC";

$id_xml = 0;

$resultat_xml1=mysql_query($req_xml1) or

die("verifier la requete req_xml1");

$row_xml1=mysql_fetch_array($resultat_xml1);

if($row_xml1 != 0)

$id_xml = $row_xml1["id_fich"] + 1;

$req_xml2="INSERT INTO `xml_livre` (`id_fich`,

`nom_fich`) VALUES (\"$id_xml\", \"$f\")";

$resultat_xml2=mysql_query($req_xml2) or

die("verifier la requete req_xml2");

mysql_close($link_bd_xml);

$file=fopen($f,'w');

fwrite($file,"<?xml version=\"1.0\" encoding=\"utf-8\"

?><?xml-stylesheet type=\"text/xsl\" href=\"cat_mot.xsl\"?><projet>");

if( $num_row >0 && !mysql_error()){

while($row=mysql_fetch_array($resultat)){

$nom_liv=$row["nom_liv"];

fwrite($file,"<livre>");

fwrite($file,"<nom_livre>");fwrite($file,"$nom_liv");fwrite($file,"</nom_livre>");

fwrite($file,"</livre>");

echo $row["nom_liv"];

echo "<BR>";

}

echo "</center>";

fwrite($file,"</projet>");

fclose($file);

print"<p><A HREF=\"$f\"><input

value=\"Version XML\" type=\"submit\"></A>";

}

RAPPORT DE TP TELEMATIQUE 2008/2009

40

else{

echo "<BR>aucun resultat3";

}

}

}

}

echo "</td>";

echo "</tr><br>";

?>

</center>

<tr>

<td bordercolor="#f9e56d"><center>

<p><A HREF = "rech.php"><input value="recherche" type="submit"> </A></p>

<p><A HREF = "choix.php"><input value="HOME" type="submit"></A></p>

<p><A HREF = "index.php"><input value="deconnecter" type="submit"></A></p>

</center>

</td>

</tr>

</table>

<br>

</td>

</tr>

</table>

<? } ?>

</center>

</Body>

</html>

fonction.php : <?php //session_start();?>

<?php

function Connexion()

{

$host="localhost";

$bd="projet";

$user="root";

$pwd="";

$link=mysql_connect($host,$user,$pwd);

if(!$link)

{

echo ("connexion impossible");

return false;

}

$select=mysql_select_db($bd);

if(!$select)

{

echo ("Base de donnée introuvable");

return false;

}

return true;

}

?>

RAPPORT DE TP TELEMATIQUE 2008/2009

41

2ème partie XML et XSL(WEB): Pour cette partie on va interpréter les résultats de recherche des livres dans des fichiers xml

Tous les fichiers XML générées, leurs noms sous l’un des formes suivantes : Rech _‘mot clé’_’catégorie’_’date et heure de création’.xml

Rech _tous_’catégorie’_’date et heure de création’.xml

Rech _‘mot clé’_’date et heure de création’.xml

Rech _tous_’date et heure de création’.xml

Exemple d’un code de génération de.XML « mot clé dans une catégorie » :

$f = "rech_'".$mot_cle."'_".$row1["nom_cat"]."_".$date_act."_".$heure_act.".xml";

$file=fopen($f,'w');

fwrite($file,"<?xml version=\"1.0\" encoding=\"utf-8\" ?><?xml-stylesheet type=\"text/xsl\" href=\"cat_mot.xsl\"?>

<projet>");

while($row=mysql_fetch_array($resultat))

{

echo $row["nom_liv"];

$nom_liv = $row["nom_liv"];

echo "<BR>";

fwrite($file,"

<livre>");fwrite($file,"

<nom_livre>");fwrite($file,"$nom_liv");fwrite($file,"</nom_livre>");fwrite($file,"

<categorie>");fwrite($file,"$catig");fwrite($file,"</categorie>");fwrite($file,"

</livre>");}fwrite($file,"

</projet>");

fclose($file);

print"<p><A HREF=\"$f\"><input value=\"Version XML\" type=\"submit\"></A>";

Le fichier XML créé « rech_'i'_informatique_19-12-2008_04-28-01.xml » :

<?xml version="1.0" encoding="utf-8" ?><?xml-stylesheet type="text/xsl" href="cat_mot.xsl"?>

<projet>

<livre>

<nom_livre>Système d'exploitation</nom_livre>

<categorie>informatique</categorie>

</livre>

<livre>

<nom_livre>Unix</nom_livre>

<categorie>informatique</categorie>

</livre>

<livre>

<nom_livre>Windows</nom_livre>

<categorie>informatique</categorie>

</livre>

</projet>

Le fichier XSL pour Recherche de livre cat_mot.xsl:

<?xml version='1.0'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<html>

<body>

<table border="1">

<tr bgcolor="#FFFF00">

<td>titre</td>

RAPPORT DE TP TELEMATIQUE 2008/2009

42

<td>catégorie</td>

</tr>

<xsl:for-each select="projet/livre">

<tr>

<td><xsl:value-of select="nom_livre"/></td>

<td><xsl:value-of select="categorie"/></td>

</tr>

</xsl:for-each>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>

TOUS LES CONSULTATION GENERENT DES FICHIERS XML(NOTE,DATE,LIVRE) :

LES FICHIERS ET LEUR FICHIERS XSL :

Le fichier XML créé « notes_salmen_hitana_micro onde_19-12-2008_05-16-32.xml» :

<?xml version="1.0" encoding="utf-8" ?><?xml-stylesheet type="text/xsl" href="note_devoir.xsl"?> <projet> <M>

<note_matiere> <matiere>micro onde</matiere>

<exam>devoir surveill</exam> <note>13</note>

</note_matiere> <note_matiere>

<matiere>micro onde</matiere> <exam>examen</exam>

<note>2</note> </note_matiere> <note_matiere>

<matiere>micro onde</matiere> <exam>TP</exam>

<note>20</note> </note_matiere>

</M> </projet>

Le fichier XSL pour NOTE note_devoir.xsl:

<?xml version='1.0'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<html>

<body>

<table border="1">

<tr bgcolor="#FFFF00">

<td>matiere</td>

<td>devoir</td>

<td>note</td>

</tr>

<xsl:for-each select="projet/M">

<xsl:for-each select="note_matiere">

<tr>

<td><xsl:value-of select="matiere"/></td>

RAPPORT DE TP TELEMATIQUE 2008/2009

43

<td><xsl:value-of select="exam"/></td>

<td><xsl:value-of select="note"/></td>

</tr>

</xsl:for-each>

</xsl:for-each>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>

Le fichier XML créé « date_devoir_micro onde_19-12-2008_05-26-47.xml» :

<?xml version="1.0" encoding="utf-8" ?><?xml-stylesheet type="text/xsl" href="date_devoir2.xsl"?>

<projet>

<M>

<date_matiere>

<matiere>anglais</matiere>

<exam>examen</exam>

<date>2009-01-04</date>

</date_matiere>

<date_matiere>

<matiere>anglais</matiere>

<exam>devoir surveille</exam>

<date>2009-01-22</date>

</date_matiere>

<date_matiere>

<matiere>anglais</matiere>

<exam>TP</exam>

<date>2008-12-05</date>

</date_matiere>

</M>

</projet>

Le fichier XSL pour DATE date_devoir.xsl:

<?xml version='1.0'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<html>

<body>

<table border="1">

<tr bgcolor="#FFFF00">

<td>matiere</td>

<td>devoir</td>

<td>date</td>

</tr>

<xsl:for-each select="projet/M">

<xsl:for-each select="date_matiere">

<tr>

<td><xsl:value-of select="matiere"/></td>

<td><xsl:value-of select="exam"/></td>

<td><xsl:value-of select="date"/></td>

</tr>

</xsl:for-each>

</xsl:for-each>

RAPPORT DE TP TELEMATIQUE 2008/2009

44

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>

Deuxieme partie site wap dynamique :

Outils utilisé :

• waptor : un editeur de fichier wap

• openwave simulator : simulator wap

langage utilisé :

• sql pour les requetes et php et wml pour la création des page .

index.wml

<?xml version="1.0"?>

<!-- created by WAPtor (http://www.waptop.net/) -->

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<!-- THIS IS THE FIRST CARD IN THE DECK -->

<card id="c1" title=Bienvenue">

<onevent type="ontimer">

<go href="#c2"/>

</onevent>

<timer value="100"/>

<body bgcolor=' lightgrey'>

<center><strong>INSAT</strong><br/>

<FONT color="#0000CD">

<i>Projet<br/> de <br/>telematique</i></center><br/>

<center><img alt="INSAT" src="images1.wbmp" align="middle" width="50" height="50"/></center>

</card>

<card id="c2" title="connexion">

login:<br/>

<input type="text" name="login" value="" /> <br/>

password:<br/>

<input type="password" name="pass" value="" /> <br/>

<anchor title="connexion">connexion

<go href="test.php" method="get">

RAPPORT DE TP TELEMATIQUE 2008/2009

45

<postfield name="login" value="$(login)"/>

<postfield name="pass" value="$(pass)"/>

</go>

</card>

</wml>

test.php

<?php

header("Content-Type: text/vnd.wap.wml");

echo '<'.'?xml version="1.0" encoding="iso-8859-1"?'.'>';

?>

<!DOCTYPE wml PUBLIC>

<wml>

<card id="card1" title="Votre Choix"> <p>

<?php

$login= $_GET['login'];

$pass=$_GET['pass'];

//paramètres de connexion

$server="localhost";

$user="root";

$pwd="";

$base="projet";

//connexion avec le serveur

$connect=mysql_connect($server,$user,$pwd) or die ("impossible de se connecter au serveur");

//selection de la base de donnees

mysql_select_db($base,$connect) or die ("impossible de se connecter a la base de données");

//affichage

$sql="SELECT * FROM etudient where(login='$login' AND pass='$pass')";

$result=mysql_query($sql) or die ('Erreur '.$sql.' '.mysql_error());

$num_row=mysql_num_rows($result);

if( $num_row == 1 && !mysql_error())

{

print"<onevent type=\"ontimer\"><go href=\"choix.wml\"/></onevent>";

print"<timer value=\"50\"/>";

print"<u><strong><center>";

print"Bienvenue";

print"<br/></strong></center></u>";

print"<br/><i><b><FONT color=\"#0000CD\"><center>";

while($row=mysql_fetch_row($result))

{

echo($row[3]);

print"<br/>";

echo($row[4]);

RAPPORT DE TP TELEMATIQUE 2008/2009

46

}

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"ok.wbmp\" width=\"50\" height=\"50\"/></center>";

}

else

{

print"<onevent type=\"ontimer\"><go href=\"index.wml\"/></onevent>";

print"<timer value=\"50\"/>";

print"<u><strong><center><FONT color=\"#FF0000\">";

print"erreur verifier vos parametres !";

print"<br/></strong></center></u>";

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"echec.wbmp\" width=\"50\" height=\"50\"/></center>";

}

?>

</p>

</card>

</wml>

RAPPORT DE TP TELEMATIQUE 2008/2009

47

choix.wml

<?xml version="1.0"?>

<!-- created by WAPtor (http://www.waptop.net/) -->

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<!-- THIS IS THE FIRST CARD IN THE DECK -->

<card id="c1" title="menu">

<body bgcolor=' lightgrey'>

<center><img alt="INSAT" src="images1.wbmp" align="middle" width="50" height="50"/></center>

<center>

<a href='date.wml'><input value="dates des examens" type="submit"></a>

<a href='note.wml'><input value="notes des examens" type="submit"></a>

<a href='livre.wml'><input value="livres disponibles " type="submit"></a>

</center>

</card>

</wml>

date.wml

<?xml version="1.0"?>

RAPPORT DE TP TELEMATIQUE 2008/2009

48

<!-- created by WAPtor (http://www.waptop.net/) -->

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<!-- THIS IS THE FIRST CARD IN THE DECK -->

<card id="c1" title="consultation des dates des examens">

<body bgcolor=' lightgrey'>

<center><img alt="INSAT" src="images1.wbmp" align="middle" width="50" height="50"/></center>

<FONT color="#0000CD"><u><i><strong>matiere:</strong></i></u>

<br/>

<input type="text" name="matiere" value="" /> <br/>

<anchor title="consulter">Consulter

<go href="consulte_date.php" method="get">

<postfield name="matiere" value="$(matiere)"/><br/>

<a href='liste.php'><input type="submit" value="Liste des matieres" /></a>

<a href='choix.wml'><input type="submit" value="Retour" /></a>

</card>

</wml>

consulte_date.php

<?php

header("Content-Type: text/vnd.wap.wml");

echo '<'.'?xml version="1.0" encoding="iso-8859-1"?'.'>';

?>

RAPPORT DE TP TELEMATIQUE 2008/2009

49

<!DOCTYPE wml PUBLIC>

<wml>

<card id="card1" title="dates des examens"> <p>

<?php

$matiere=$_GET['matiere'];

//paramètres de connexion

$server="localhost";

$user="root";

$pwd="";

$base="projet";

//connexion avec le serveur

$connect=mysql_connect($server,$user,$pwd) or die ("impossible de se connecter au serveur");

//selection de la base de donnees

mysql_select_db($base,$connect) or die ("impossible de se connecter a la base de données");

//réquete

$sql="SELECT * FROM matiere where (lib_mat='$matiere')";

$result=mysql_query($sql) or die ('Erreur '.$sql.' '.mysql_error());

while($row=mysql_fetch_row($result))

{

$c=$row[0];

}

$num_row=mysql_num_rows($result);

if( $num_row == 1 && !mysql_error())

{

$sql="SELECT * FROM dev_mat where(id_mat='$c')";

$result=mysql_query($sql) or die ('Erreur '.$sql.' '.mysql_error());

$num_row3=mysql_num_rows($result);

if( $num_row3 >= 1 && !mysql_error())

{

print"<body bgcolor=' lightgrey'><u><strong><center>";

print"Resultat de la consultation";

print"<br/></strong></center></u>";

print"<br/><i><b><FONT color=\"#0000CD\"><center>";

while($row=mysql_fetch_row($result))

{

if ($row[0]==0)

{

echo"date de DS : ";

echo($row[2]);

print"<br/>";

}

if ($row[0]==1)

{

echo"date de l'Examen : ";

echo($row[2]);

RAPPORT DE TP TELEMATIQUE 2008/2009

50

print"<br/>";

}

if ($row[0]==2)

{

echo"date du TP : ";

echo($row[2]);

print"<br/>";

}

}

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"ok.wbmp\" width=\"50\"

height=\"50\"/></center>";

print"<a href='choix.wml'><input type=\"submit\" value=\"Continuer\" /></a>";

print"<a href='date.wml'><input type=\"submit\" value=\"Retour\" /></a>";

}

else

{

print"<onevent type=\"ontimer\"><go href=\"date.wml\"/></onevent>";

print"<timer value=\"50\"/>";

print"<body bgcolor=' lightgrey'><u><strong><center><FONT color=\"#FF0000\">";

print"erreur verifier vos parametres !";

print"<br/></strong></center></u>";

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"echec.wbmp\" width=\"50\"

height=\"50\"/></center>";

}

}

else

{

print"<onevent type=\"ontimer\"><go href=\"date.wml\"/></onevent>";

print"<timer value=\"50\"/>";

print"<body bgcolor=' lightgrey'><u><strong><center><FONT color=\"#FF0000\">";

print"erreur verifier vos parametres !";

print"<br/></strong></center></u>";

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"echec.wbmp\" width=\"50\" height=\"50\"/></center>";

}

?>

</p>

</card>

</wml>

RAPPORT DE TP TELEMATIQUE 2008/2009

51

note.wml

<?xml version="1.0"?>

<!-- created by WAPtor (http://www.waptop.net/) -->

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<!-- THIS IS THE FIRST CARD IN THE DECK -->

<card id="c1" title="consultation des notes des examens">

<body bgcolor=' lightgrey'>

<center><img alt="INSAT" src="images1.wbmp" align="middle" width="50" height="50"/></center>

<FONT color="#0000CD"><u><i><strong>Nom:</strong></i></u>

<br/>

<input type="text" name="nom" value="" /> <br/>

<FONT color="#0000CD"><u><i><strong>Prenom:</strong></i></u>

<br/>

<input type="text" name="prenom" value="" /> <br/>

<FONT color="#0000CD"><u><i><strong>Matiere:</strong></i></u>

<br/>

<input type="text" name="matiere" value="" /> <br/>

<anchor title="consulter">Consulter

<go href="consulte_note.php" method="get">

<postfield name="nom" value="$(nom)"/>

<postfield name="prenom" value="$(prenom)"/>

<postfield name="matiere" value="$(matiere)"/><br/>

<a href='liste.php'><input type="submit" value="Liste des matieres" /></a>

<a href='choix.wml'><input type="submit" value="Retour" /></a>

</card>

</wml>

consulte_note.php

<?php

header("Content-Type: text/vnd.wap.wml");

echo '<'.'?xml version="1.0" encoding="iso-8859-1"?'.'>';

?>

<!DOCTYPE wml PUBLIC>

<wml>

<card id="card1" title="Notes des examens"> <p>

<?php

RAPPORT DE TP TELEMATIQUE 2008/2009

52

$nom= $_GET['nom'];

$prenom=$_GET['prenom'];

$matiere=$_GET['matiere'];

//paramètres de connexion

$server="localhost";

$user="root";

$pwd="";

$base="projet";

//connexion avec le serveur

$connect=mysql_connect($server,$user,$pwd) or die ("impossible de se connecter au serveur");

//selection de la base de donnees

mysql_select_db($base,$connect) or die ("impossible de se connecter a la base de données");

//réquete

$sql="SELECT * FROM etudient where (pre_etu='$prenom'and nom_etu='$nom')";

$result=mysql_query($sql) or die ('Erreur '.$sql.' '.mysql_error());

while($row=mysql_fetch_row($result))

{

$c=$row[0];

}

$num_row=mysql_num_rows($result);

if( $num_row == 1 && !mysql_error())

{

$sql="SELECT * FROM matiere where(lib_mat='$matiere')";

$result=mysql_query($sql) or die ('Erreur '.$sql.' '.mysql_error());

while($row=mysql_fetch_row($result))

{

$b=$row[0];

}

$num_row2=mysql_num_rows($result);

if( $num_row2 == 1 && !mysql_error())

{

$sql="SELECT * FROM dev_mat_etu where(id_etu='$c' AND id_mat='$b')";

$result=mysql_query($sql) or die ('Erreur '.$sql.' '.mysql_error());

$num_row3=mysql_num_rows($result);

if( $num_row3 >= 1 && !mysql_error())

{

print"<body bgcolor=' lightgrey'><u><strong><center>";

print"Resultat de la consultation";

print"<br/></strong></center></u>";

print"<br/><i><b><FONT color=\"#0000CD\"><center>";

while($row=mysql_fetch_row($result))

{

if ($row[0]==0)

{

echo"DS de ";

echo $matiere;

echo " : ";

echo($row[3]);

RAPPORT DE TP TELEMATIQUE 2008/2009

53

}

print"<br/>";

if ($row[0]==1)

{

echo"Examen de ";

echo $matiere;

echo " : ";

echo($row[3]);

}

print"<br/>";

if ($row[0]==2)

{

echo"TP de ";

echo $matiere;

echo " : ";

echo($row[3]);

}

}

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"ok.wbmp\" width=\"50\"

height=\"50\"/></center>";

print"<a href='choix.wml'><input type=\"submit\" value=\"Continuer\" /></a>";

print"<a href='note.wml'><input type=\"submit\" value=\"Retour\" /></a>";

}

else

{

print"<onevent type=\"ontimer\"><go href=\"note.wml\"/></onevent>";

print"<timer value=\"50\"/>";

print"<body bgcolor=' lightgrey'><u><strong><center><FONT color=\"#FF0000\">";

print"erreur verifier vos parametres !";

print"<br/></strong></center></u>";

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"echec.wbmp\" width=\"50\"

height=\"50\"/></center>";

}

}

else

{

print"<onevent type=\"ontimer\"><go href=\"note.wml\"/></onevent>";

print"<timer value=\"50\"/>";

print"<body bgcolor=' lightgrey'><u><strong><center><FONT color=\"#FF0000\">";

print"erreur verifier vos parametres !";

print"<br/></strong></center></u>";

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"echec.wbmp\" width=\"50\" height=\"50\"/></center>";

}

RAPPORT DE TP TELEMATIQUE 2008/2009

54

}

else

{

print"<onevent type=\"ontimer\"><go href=\"note.wml\"/></onevent>";

print"<timer value=\"50\"/>";

print"<body bgcolor=' lightgrey'><u><strong><center><FONT color=\"#FF0000\">";

print"erreur verifier vos parametres !";

print"<br/></strong></center></u>";

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"echec.wbmp\" width=\"50\" height=\"50\"/></center>";

}

?>

</p>

</card>

</wml>

livre.wml

<?xml version="1.0"?>

<!-- created by WAPtor (http://www.waptop.net/) -->

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<!-- THIS IS THE FIRST CARD IN THE DECK -->

<card id="c1" title="consulter les livres de la bibliothéque">

<body bgcolor=' lightgrey'>

<center><img alt="INSAT" src="images1.wbmp" align="middle" width="50" height="50"/><br/>

<a href='theme.wml'><input type="submit" value="Recherche par theme" /></a><br/>

<a href='motcle.wml'><input type="submit" value="Recherche par mot cle" /></a><br/>

<a href='choix.wml'><input type="submit" value="Retour" /></a><br/></center>

</card>

</wml>

motcle.wml

<?xml version="1.0"?>

<!-- created by WAPtor (http://www.waptop.net/) -->

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<!-- THIS IS THE FIRST CARD IN THE DECK -->

<card id="c1" title="Recherche des livre par mot clé">

<body bgcolor=' lightgrey'>

<center><img alt="INSAT" src="images1.wbmp" align="middle" width="50" height="50"/></center>

RAPPORT DE TP TELEMATIQUE 2008/2009

55

<FONT color="#0000CD"><u><i><strong>Mot cle:</strong></i></u>

<br/>

<input type="text" name="cle" value="" /> <br/>

<anchor title="consulter">Consulter

<go href="rech_cle.php" method="get">

<postfield name="cle" value="$(cle)"/>

<br/>

<a href='livre.wml'><input type="submit" value="Retour" /></a>

</card>

</wml>

theme.wml

<?xml version="1.0"?>

<!-- created by WAPtor (http://www.waptop.net/) -->

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<!-- THIS IS THE FIRST CARD IN THE DECK -->

<card id="c1" title="Recherche de livre par theme">

<body bgcolor=' lightgrey'>

<center><img alt="INSAT" src="images1.wbmp" align="middle" width="50" height="50"/></center>

<a href='categorie.php'><input type="submit" value="liste de themes" /></a><br/><br/>

<FONT color="#0000CD"><u><i><strong>Theme:</strong></i></u>

<br/>

<input type="text" name="theme" value="" /> <br/>

<anchor title="consulter">Consulter

<go href="rech_theme.php" method="get">

<postfield name="theme" value="$(theme)"/>

<br/>

<a href='livre.wml'><input type="submit" value="Retour" /></a>

</card>

</wml>

rech_theme.php

<?php

header("Content-Type: text/vnd.wap.wml");

echo '<'.'?xml version="1.0" encoding="iso-8859-1"?'.'>';

?>

<!DOCTYPE wml PUBLIC>

<wml>

<card id="card1" title="livre par théme"> <p>

<?php

RAPPORT DE TP TELEMATIQUE 2008/2009

56

$theme=$_GET['theme'];

//paramètres de connexion

$server="localhost";

$user="root";

$pwd="";

$base="projet";

//connexion avec le serveur

$connect=mysql_connect($server,$user,$pwd) or die ("impossible de se connecter au serveur");

//selection de la base de donnees

mysql_select_db($base,$connect) or die ("impossible de se connecter a la base de données");

//réquete

$sql="SELECT * FROM categorie where (nom_cat='$theme')";

$result=mysql_query($sql) or die ('Erreur '.$sql.' '.mysql_error());

while($row=mysql_fetch_row($result))

{

$c=$row[0];

}

$num_row=mysql_num_rows($result);

if( $num_row == 1 && !mysql_error())

{

$sql="SELECT * FROM livre where(id_cat='$c')";

$result=mysql_query($sql) or die ('Erreur '.$sql.' '.mysql_error());

$num_row3=mysql_num_rows($result);

if( $num_row3 >= 1 && !mysql_error())

{

print"<body bgcolor=' lightgrey'><u><strong><center>";

print"Resultat de la consultation";

print"<br/></strong></center></u>";

print"<br/><i><b><FONT color=\"#0000CD\"><center>";

while($row=mysql_fetch_row($result))

{

echo $row[1];

print"<br/>";

}

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"ok.wbmp\" width=\"50\"

height=\"50\"/></center>";

print"<a href='choix.wml'><input type=\"submit\" value=\"Continuer\" /></a>";

print"<a href='theme.wml'><input type=\"submit\" value=\"Retour\" /></a>";

}

else

{

RAPPORT DE TP TELEMATIQUE 2008/2009

57

print"<onevent type=\"ontimer\"><go href=\"theme.wml\"/></onevent>";

print"<timer value=\"50\"/>";

print"<body bgcolor=' lightgrey'><u><strong><center><FONT color=\"#FF0000\">";

print"erreur verifier votre requette !";

print"<br/></strong></center></u>";

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"echec.wbmp\" width=\"50\"

height=\"50\"/></center>";

}

}

else

{

print"<onevent type=\"ontimer\"><go href=\"theme.wml\"/></onevent>";

print"<timer value=\"50\"/>";

print"<body bgcolor=' lightgrey'><u><strong><center><FONT color=\"#FF0000\">";

print"erreur verifier votre requette !";

print"<br/></strong></center></u>";

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"echec.wbmp\" width=\"50\" height=\"50\"/></center>";

}

?>

</p>

</card>

</wml>

liste.php :

<?php

header("Content-Type: text/vnd.wap.wml");

echo '<'.'?xml version="1.0" encoding="iso-8859-1"?'.'>';

?>

<!DOCTYPE wml PUBLIC>

<wml>

<card id="card1" title="Votre Choix"> <p>

<?php

//paramètres de connexion

$server="localhost";

$user="root";

$pwd="";

$base="projet";

//connexion avec le serveur

$connect=mysql_connect($server,$user,$pwd) or die ("impossible de se connecter au serveur");

//selection de la base de donnees

mysql_select_db($base,$connect) or die ("impossible de se connecter a la base de données");

RAPPORT DE TP TELEMATIQUE 2008/2009

58

//réquete

$sql="SELECT * FROM matiere";

$result=mysql_query($sql) or die ('Erreur '.$sql.' '.mysql_error());

$num_row=mysql_num_rows($result);

if( $num_row >= 1 && !mysql_error())

{

print"<body bgcolor=' lightgrey'><u><strong><center>";

print"Resultat de la consultation";

print"<br/></strong></center></u>";

print"<br/><i><b><FONT color=\"#0000CD\"><center>";

while($row=mysql_fetch_row($result))

{

echo $row[1];

print"<br/>";

}

print"<do type=\"accept\" label=\"Retour\"><prev/></do>";

}

else

{

print"<onevent type=\"ontimer\"><go href=\"note.wml\"/></onevent>";

print"<timer value=\"50\"/>";

print"<body bgcolor=' lightgrey'><u><strong><center><FONT color=\"#FF0000\">";

print"aucune matiere dans la base de donnée !";

print"<br/></strong></center></u>";

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"echec.wbmp\" width=\"50\" height=\"50\"/></center>";

}

?>

</p>

</card>

</wml>

categorie.php

<?php

header("Content-Type: text/vnd.wap.wml");

echo '<'.'?xml version="1.0" encoding="iso-8859-1"?'.'>';

?>

<!DOCTYPE wml PUBLIC>

<wml>

<card id="card1" title="Votre Choix"> <p>

<?php

RAPPORT DE TP TELEMATIQUE 2008/2009

59

//paramètres de connexion

$server="localhost";

$user="root";

$pwd="";

$base="projet";

//connexion avec le serveur

$connect=mysql_connect($server,$user,$pwd) or die ("impossible de se connecter au serveur");

//selection de la base de donnees

mysql_select_db($base,$connect) or die ("impossible de se connecter a la base de données");

//réquete

$sql="SELECT * FROM categorie";

$result=mysql_query($sql) or die ('Erreur '.$sql.' '.mysql_error());

$num_row=mysql_num_rows($result);

if( $num_row >= 1 && !mysql_error())

{

print"<body bgcolor=' lightgrey'><u><strong><center>";

print"Resultat de la consultation";

print"<br/></strong></center></u>";

print"<br/><i><b><FONT color=\"#0000CD\"><center>";

while($row=mysql_fetch_row($result))

{

echo $row[1];

print"<br/>";

}

print"<a href='theme.wml'><input type=\"submit\" value=\"Retour\" /></a>";

}

else

{

print"<onevent type=\"ontimer\"><go href=\"theme.wml\"/></onevent>";

print"<timer value=\"50\"/>";

print"<body bgcolor=' lightgrey'><u><strong><center><FONT color=\"#FF0000\">";

print"aucune catégorie dans la base de donnée !";

print"<br/></strong></center></u>";

print"</center></b></i><br/><center><img alt=\"INSAT\" src=\"echec.wbmp\" width=\"50\" height=\"50\"/></center>";

}

?>

</p>

</card>

</wml>

RAPPORT DE TP TELEMATIQUE 2008/2009

60

Exemple de consultation :

RAPPORT DE TP TELEMATIQUE 2008/2009

61