{MySQL} Problème formulaire de modification de don

Résolu/Fermé
killersources Messages postés 23 Date d'inscription lundi 15 juin 2009 Statut Membre Dernière intervention 18 janvier 2014 - 15 juin 2009 à 21:24
Christounet Messages postés 1264 Date d'inscription mercredi 26 septembre 2007 Statut Membre Dernière intervention 29 juillet 2010 - 16 juin 2009 à 11:18
Bonjour à tous,

J'ai créé un formulaire de modification de données mais lorsque que je veux enregistrer les modifications, il me remet les données de base et enregistre rien.... La fonction supprimer quant à elle fonctionne bien. Quelqu'un a une idée???

<?php

include ("variables.inc.php");
include ("identification.inc.php");

$liendb = mysql_connect ("localhost", "", "");
mysql_select_db ("");

if ($_REQUEST['action']=="modifier")
{

if ($_REQUEST['contrat']!="oui" &&
$_REQUEST['contrat']!="non")
die("ERREUR : Définir le contrat");

$sql = "UPDATE FROM clients SET Societe = '".$_REQUEST['nom']."',".
"Adresse = '".$_REQUEST['adresse']."',".
"codepostal = '".$_REQUEST['cp']."',".
"ville = '".$_REQUEST['ville']."',".
"telephone = '".$_REQUEST['tel']."',".
"fax = '".$_REQUEST['fax']."',".
"tva = '".$_REQUEST['tva']."',".
"responsable = '".$_REQUEST['responsable']."',".
"contrat = '".$_REQUEST['contrat']."',".
"nbremachine = '".$_REQUEST['machine']."',".
"prix = '".$_REQUEST['prix']."',".
"nbrevisite = '".$_REQUEST['visite']."',".
"indice = '".$_REQUEST['indice']."',".
" WHERE id_client = '".$_REQUEST['id']."'";

mysql_query ($sql);
}
elseif ($_REQUEST['action']=="suppr" && $_REQUEST['id']>=1)
{
$sql = "DELETE FROM clients WHERE id_client='".$_REQUEST['id']."'";
mysql_query ($sql);
header("Location: admin.php");
}

include("haut.inc.php");

echo "<p align=left> Fiche client    [".$_REQUEST['id']."]</p>";

$sql = "SELECT * FROM clients WHERE id_client='".$_REQUEST['id']."'";
$resultat = mysql_query ($sql);
$clients = mysql_fetch_array ($resultat)

?>

<form action="clients_edit.php" method="post">
<input type="hidden" name="enregistre" value="oui" />
<input type="hidden" name="id" value="<?php echo $_REQUEST['id']; ?>" />

<table width="600">
<tr>
<td width="200">Socété</td>
<td width="400"><input name="nom" type="text" value="<?php echo $clients['Societe']; ?>" size="20" /></td>
</tr>
<tr>
<td>Adresse</td>
<td><textarea name="adresse" cols="60"><?php echo $clients['Adresse']; ?></textarea></td>
</tr>
<tr>
<td>Code Postal</td>
<td><input type="text" name="cp" value="<?php echo $clients['codepostal']; ?>" /></td>
</tr>
<tr>
<td>Ville</td>
<td><input type="text" name="ville" value="<?php echo $clients['ville']; ?>" /></td>
</tr>
<tr>
<td>Teléphone</td>
<td><input type="text" name="tel" value="<?php echo $clients['telephone']; ?>" /></td>
</tr>
<tr>
<td>Fax</td>
<td><input type="text" name="fax" value="<?php echo $clients['fax']; ?>" /></td>
</tr>
<tr>
<td>TVA</td>
<td><input type="text" name="tva" value="<?php echo $clients['tva']; ?>" /></td>
</tr>
<tr>
<td>Nom du responsable</td>
<td><input type="text" name="responsable" value="<?php echo $clients['responsable']; ?>" /></td>
</tr>
<tr>
<td>contrat</td>
<td>
Oui <input type="radio" name="contrat" value="oui"
<?php if ($clients['contrat'] == "oui") echo "CHECKED"; ?>> -
Non <input type="radio" name="contrat" value="non"
<?php if ($clients['contrat'] == "non") echo "CHECKED"; ?>>
</td>
</tr>
<tr>
<td>Nombre de machines</td>
<td><input type="text" name="machine" value="<?php echo $clients['nbremachine']; ?>" /></td>
</tr>
<tr>
<td>Prix du contrat</td>
<td><input type="text" name="prix" value="<?php echo $clients['prix']; ?>" /></td>
</tr>
<tr>
<td>Nombre de visite annuelle</td>
<td><input type="text" name="visite" value="<?php echo $clients['nbrevisite']; ?>" /></td>
</tr>
<tr>
<td>Indice de départ</td>
<td><input type="text" name="indice" value="<?php echo $clients['indice']; ?>" /></td>
</tr>
</table>

<br/>

<select name="action">
<option value="modifier"> Enregistrer la fiche </option>
<option value="suppr"> Supprimer la fiche </option>
</select>

<input type="submit" value="effectuer">

</form>

</body>
</html>

<?php

mysql_close ($liendb);

?>
A voir également:

1 réponse

Christounet Messages postés 1264 Date d'inscription mercredi 26 septembre 2007 Statut Membre Dernière intervention 29 juillet 2010 1 385
16 juin 2009 à 11:18
Bonjour,

Il ne faut pas utiliser le mot FROM dans ton ordre update
$sql = "UPDATE clients SET Societe = '".$_REQUEST['nom']."',".
"Adresse = '".$_REQUEST['adresse']."',".
"codepostal = '".$_REQUEST['cp']."',".
"ville = '".$_REQUEST['ville']."',".
"telephone = '".$_REQUEST['tel']."',".
"fax = '".$_REQUEST['fax']."',".
"tva = '".$_REQUEST['tva']."',".
"responsable = '".$_REQUEST['responsable']."',".
"contrat = '".$_REQUEST['contrat']."',".
"nbremachine = '".$_REQUEST['machine']."',".
"prix = '".$_REQUEST['prix']."',".
"nbrevisite = '".$_REQUEST['visite']."',".
"indice = '".$_REQUEST['indice']."',".
" WHERE id_client = '".$_REQUEST['id']."'"; 

A plus
0