Envoyer une variable d'un script PHP à un autre
Bonjour ,
J'ai deux scripts php !
Voici le premier :
Code:
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
| <table width="22%" border="1">
<tr>
<td width="64%"><p><a href="index.php">Accueil</a></p>
<p><a href="CreationBase.php">Creer Base</a></p>
<p><a href="creationClient.php">Creer un client</a></p>
<p><a href="AffBase.php">Afficher Base</a></p>
<p><a href="AffBaseParVille.php">Afficher Base par ville</a></p>
<p><a href="modifierclient.php">Modifier un client</a></p>
</td>
<td width="36%">
<?php
// Configuration de la connexion à la base de données
define('MYSQL_HOTE', 'localhost');
define('MYSQL_UTILISATEUR', 'root');
define('MYSQL_MOT_DE_PASSE', '');
define('MYSQL_BASE_DE_DONNEES', 'AquaVendee');
$nom = isset($_POST['Nom']) ? $_POST['Nom'] : '';
// Connexion à la base de donnée
mysql_connect(MYSQL_HOTE, MYSQL_UTILISATEUR, MYSQL_MOT_DE_PASSE) or die('<h1>Connexion au serveur impossible !</h1>');
mysql_select_db(MYSQL_BASE_DE_DONNEES) or die('<h1>Connexion impossible à la base</h1>');
echo '<form method="post" action="modifierClient.php">';
// Affichage du langage choisi
if ($nom) {
$query = mysql_query("SELECT * FROM client WHERE Nom='$nom';") or die ( mysql_error() );
$array = mysql_fetch_array($query);
// echo 'Vous avez choisi le nom : ' . $array['Nom'];
}
// Début du script
$query = mysql_query("SELECT Distinct Nom from client;") or die (mysql_error());
if ($query)
{
echo '<form method="post">';
echo '<select name="Nom">';
while ($array = mysql_fetch_array($query))
{
if ($nom == $array["Nom"])
{
echo '<option value="' . $array['Nom'] . '" selected>' . $array['Nom'] . '</option>';
}
else
{
echo '<option value="'.$array['Nom'] . '">' . $array['Nom'] . '</option>';
}
}
echo '</select>';
echo '<input type="submit" value="OK">';
echo '</form>';
}
$prenom = isset($_POST['Prenom']) ? $_POST['Prenom'] : '';
// Connexion à la base de donnée
mysql_connect(MYSQL_HOTE, MYSQL_UTILISATEUR, MYSQL_MOT_DE_PASSE) or die('<h1>Connexion au serveur impossible !</h1>');
mysql_select_db(MYSQL_BASE_DE_DONNEES) or die('<h1>Connexion impossible à la base</h1>');
echo '<form method="post" action="valider.php">';
// Affichage du langage choisi
if ($prenom)
{
$query = mysql_query("SELECT * FROM client WHERE Nom='$nom';") or die ( mysql_error() );
$array = mysql_fetch_array($query);
// echo 'Vous avez choisi le nom : ' . $array['Nom'];
}
// Début du script
$query = mysql_query("SELECT Distinct Prenom from client WHERE Nom='$nom';") or die (mysql_error());
if ($query)
{
echo '<form method="post">';
echo '<select name="Prenom">';
while ($array = mysql_fetch_array($query))
{
if ($prenom == $array["Prenom"])
{
echo '<option value="' . $array['Prenom'] . '" selected>' . $array['Prenom'] . '</option>';
}
else
{
echo '<option value="'.$array['Prenom'] . '">' . $array['Prenom'] . '</option>';
}
}
echo '</select>';
echo '<input type="submit" value="OK">';
echo '</form>';
}
echo"$nom";
mysql_close();
?>
</td>
</tr>
</table> |
Et voici le deuxieme :
Code:
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
| <?php
$prenom=$_POST["Prenom"];
$nom=$_POST["Nom"];
$f = mysql_connect ("localhost", "root", "");
mysql_select_db ("AquaVendee");
// Recuperation des valeurs des différents champs
$req ="select * from client where Prenom='$prenom' ";
$ok=mysql_query($req,$f); //retouve les données brutes
$arr = mysql_fetch_array($ok); //prend la première ligne des résultats et transforme en tableau
$prenom = $arr['Prenom']; //prend la valeur de la clé Prenom
$ville = $arr['Ville'];
$adresse = $arr['Adresse'];
$app = $arr['TypeApp'];
$dv = $arr['DateV'];
$dms = $arr['DateMs'];
$dm = $arr['DateM'];
$com = $arr['Commentaire'];
mysql_close($f);
?>
<table width="50%" border="1">
<tr>
<td width="34%"><p><a href="index.php">Accueil</a></p>
<p><a href="CreationBase.php">Creer Base</a></p>
<p><a href="creationClient.php">Creer un client</a></p>
<p><a href="AffBase.php">Afficher Base</a></p>
<p><a href="AffBaseParVille.php">Afficher Base par ville</a></p>
<p><a href="modifierclient.php">modifier un client</a></p> </td>
<td width="66%"><form method="post" action="insertionClient2.php" name="form2">
<table width="94%" border="0">
<tr>
<td width="53%">Nom</td>
<td width="47%"> <input name="nom" type="text" id="nom" value="<?php echo"$nom"?>">
</td>
</tr>
<tr>
<td>Prenom</td>
<td> <input name="prenom" type="text" id="prenom" value="<?php echo "$prenom" ?>">
</td>
</tr>
<tr>
<td>Ville</td>
<td> <input name="ville" type="text" id="ville" value="<?php echo"$ville"?>">
</td>
</tr>
<tr>
<td>Adresse</td>
<td> <input name="adresse" type="text" id="adresse" value="<?php echo "$adresse" ?>">
</td>
</tr>
<tr>
<td>Type Appareil
<td> <input name="app" type="text" id="app" value="<?php echo "$app "?>">
</td>
</tr>
<tr>
<td>Date Vente</td>
<td> <input name="dv" type="text" id="dv" value="<?php echo "$dv" ?>">
</td>
</tr>
<tr>
<tr>
<td>Date mise en Service</td>
<td> <input name="dmes" type="text" id="dmes" value="<?php echo "$dms" ?>">
</td>
</tr>
<tr>
<td>Date maintenance</td>
<td> <input name="dm" type="text" id="dm" value="<?php echo "$dm"?>">
</td>
</tr>
<tr>
<td>Commentaire</td>
<td> <input name="com" type="text" id="com" value="<?php echo "$com"?>">
</td>
</tr>
</table>
<input name="submit" type="submit" value="OK">
</form></td>
</tr>
</table>
<p> </p> |
Mon probleme c'est qu'au second script je n'arrive pas a lui passer la variable $nom alors que j'arrive a passer prenom normalement !