1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| /* code insertion mis dans le fichier ajout.php*/
<html>
<head>
<title>ajout</title>
</head>
<body>
<?
echo("hello");
//Connexion au serveur
$cnx=mysql_connect("localhost","root","");
//sélection de la base de données:
$db=mysql_select_db("msis") or die ( mysql_error());
//récupération des valeurs des champs:
//nom:
$nom = $_POST['nom'] ;
//adresse:
$adresse = $_POST['adresse'] ;
//numéro de téléphone:
$contact = $_POST['contact'] ;
//création de la requête SQL:
$sql = "INSERT INTO client (reference, nom, adresse, contact)
VALUES ( '','$nom', '$adresse', '$contact') " ;
//exécution de la requête SQL:
$requete = mysql_query($sql, $cnx) or die( mysql_error() ) ;
//affichage des résultats, pour savoir si l'insertion a été effectué:
if($requete)
{
echo("L'insertion a été correctement effectuée") ;
}
else
{
echo("L'insertion à échouée") ;
}
?>
</body>
</html>
/* code affichage mis dans le fichier affiche.php*/
<html>
<head>
<title>Affichage des données d'un client</title>
</head>
<body>
<?php
//connexion au serveur:
mysql_connect( "localhost", "root", "" ) ;
//sélection de la base de données:
$db = mysql_select_db( "msis" ) ;
if($db) echo "<center><h3><font color=red> connexion à la base avec succès </font></h3></center>";
$nom=$_POST['nom'];
$requete="select * from client where nom=$nom";
$resultat=mysql_query ("$requete");
echo "<center> Machine à déstocker</center>";
//affichage des données:
if( $data = mysql_fetch_array( $resultat ) )
{
?>
<form name="form" method="post" action="destocker.php">
<table border=1>
<tr align="center">
<td>Date</td>
<td width="186"><input type="text" name="date" value="<?php echo($data['date']) ;?>"></td>
</tr>
<tr align="center">
<td>Référence</td>
<td><input type="text" name="reference" value="<?php echo($resultat['reference']) ;?>"></td>
</tr>
<tr align="center">
<td>Nom</td>
<td><input type="text" name="nom" value="<?php echo($resultat['nom']) ;?>"></td>
</tr>
<tr align="center">
<td>Type</td>
<td><input type="text" name="type" value="<?php echo($resultat['type']) ;?>"></td>
</tr>
<tr align="center">
<td>Marque</td>
<td><input type="text" name="marque" value="<?php echo($resultat['marque']) ;?>"></td>
</tr>
<tr align="center">
<td>Observations</td>
<td><input type="text" name="observation" value="<?php echo($resultat['observation']) ;?>"></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" value="valider"></td>
</tr>
<tr align="center">
<div align="center">
<input type="submit" name="valider" value="Valider" />
<input name="annuler" type="reset" id="reset" value="Annuler" />
</div>
</tr>
</table>
</form>
<?php
}//fin if
?>
</body>
</html> |
Partager