par
cw75116 » 03 oct. 2008, 11:03
Bonjour AB, merci de ta réponse rapide.
Le double <form> c'est une erreur de frappe sur le forum..
Je n'ai pas mis d'attribut action car je déclare une variable "envoyer".
Mon code avait quelques erreurs je l'ai modifié mais ça bloque toujours.
J'utilise ce formulaire pour l'inscription avec INSERT INTO et ça marche sans problème ..
Voilà la mise à jour :
Mon code UPDATE
if(isset($_POST['envoyer'])){
$alerte = $_POST['envoyer'];
$id = $_POST['id'];
$email = addslashes(htmlentities($_POST['email']));
$pass = addslashes(htmlentities($_POST['pass']));
$pass2 = addslashes(htmlentities($_POST['pass2']));
$civilite = addslashes(htmlentities($_POST['civilite']));
$nom = addslashes(htmlentities($_POST['nom']));
$prenom = addslashes(htmlentities($_POST['prenom']));
$adresse = addslashes(htmlentities($_POST['adresse']));
$cp = addslashes(htmlentities($_POST['cp']));
$ville = addslashes(htmlentities($_POST['ville']));
$telephone = addslashes(htmlentities($_POST['telephone']));
$portable = addslashes(htmlentities($_POST['portable']));
$fax = addslashes(htmlentities($_POST['fax']));
if(isset($_POST['email'])&&($_POST['pass'])&&($_POST['pass2']))
{ mysql_query(" UPDATE clients SET
nom='$nom', prenom='$prenom', email='$email', telephone='$telephone', pass='$pass', civilite='$civilite', portable='$portable', cp='$cp', ville='$ville', adresse='$adresse', fax='$fax', pass2='$pass2' WHERE id='$id'") or die (mysql_error()) ;
echo '<center><p>OK mise a jour</p> </center>';
}
}
Mon formulaire avec apercu des champs deja remplis
session_start() ;
if ( isset( $_SESSION['email_clients'] ) )
{
$login=$_SESSION['id_clients'];
echo '<input type="hidden" name="id" value="'.$login.'" />';
$demande2 = mysql_query("SELECT * FROM clients WHERE id=$login" ) or die (mysql_error());
while ($clients = mysql_fetch_assoc($demande2))
{
//if(isset($_POST['envoyer'])){
$id = $clients['id'];
$email = $clients['email'];
$emailverif = $clients['emailverif'];
$pass = $clients['pass'];
$civilite = $clients['civilite'];
$nom = $clients['nom'];
$prenom = $clients['prenom'];
$adresse = $clients['adresse'];
$cp = $clients['cp'];
$ville = $clients['ville'];
$telephone = $clients['telephone'];
$portable = $clients['portable'];
$fax = $clients['fax'];
?>
Code : Tout sélectionner
<form method="post">
<table border="0" cellspacing="0">
<tr>
<td align="left" width="150" style="padding:10px 0 10px 0;"><b>* Identifiants</b></td>
<td> </td>
</tr>
<tr>
<td align="left" width="150">* Votre e-mail :</td>
<td><input type="text" name="email" size="20" value="<?php echo $email; ?>" /> </td>
</tr>
...
<tr>
<td align="left" width="150">Votre fax :</td>
<td><input type="text" name="fax" size="20" value="<?php echo $fax; ?>" /></td>
</tr>
<tr>
<td align="left" width="150"></td>
<td align="right" style="padding-top:10px;"><input type="submit" name="envoyer" value="Envoyer">
</td>
</tr>
</table>
</form>
<?php
echo'</div>';
}}
else { echo' VOUS N\'ETES PAS AUTORISE A VOIR CETTE PAGE. VEUILLEZ VOUS CONNECTER.';}
?>
L'affichage est dans cet ordre.
Et pourtant ça marche pour une création d'un utilisateur.
Si ça peut aider, voilà mon code de création d'utilisateur:
if(isset($_POST['envoyer'])){
$alerte = $_POST['envoyer'];
$id = addslashes(htmlentities($_POST['id'], ENT_NOQUOTES));
$email = addslashes(htmlentities($_POST['email'], ENT_NOQUOTES));
$pass2 = addslashes(htmlentities($_POST['pass2'], ENT_NOQUOTES));
$pass = addslashes(htmlentities($_POST['pass'], ENT_NOQUOTES));
$civilite = addslashes(htmlentities($_POST['civilite'], ENT_NOQUOTES));
$nom = addslashes(htmlentities($_POST['nom'], ENT_NOQUOTES));
$prenom = addslashes(htmlentities($_POST['prenom'], ENT_NOQUOTES));
$adresse = addslashes(htmlentities($_POST['adresse'], ENT_NOQUOTES));
$cp = addslashes(htmlentities($_POST['cp'], ENT_NOQUOTES));
$ville = addslashes(htmlentities($_POST['ville'], ENT_NOQUOTES));
$telephone = addslashes(htmlentities($_POST['telephone'], ENT_NOQUOTES));
$portable = addslashes(htmlentities($_POST['portable'], ENT_NOQUOTES));
$fax = addslashes(htmlentities($_POST['fax'], ENT_NOQUOTES));
if(isset($_POST['email'])&&($_POST['pass'])&&($_POST['pass2']))
{ $query="SELECT email FROM clients WHERE email='".$email."'";
$result=mysql_query($query);
if(mysql_num_rows($result)== 1)
{
echo '<div style="padding:5px;"><b>Cette adresse e-mail existe deja </b></div>';
}
else if(($pass)!=($pass2))
{
echo '<div style="padding:5px;"><b>Erreur dans la saisie du mot de passe </b></div>';
}
else{
$sql = "INSERT INTO clients VALUES
('$id', '$nom', '$prenom', '$email', '$elephone', '$pass', '$civilite', '$portable', '$cp', '$ville', '$adresse', '$fax', '$pass2') "; mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
}
}
le formulaire
Code : Tout sélectionner
<form method="post">
<table border="0" cellspacing="0">
<tr>
<td align="left" width="150" style="padding:10px 0 10px 0;"><b>* Identifiants</b></td>
<td> </td>
</tr>
...
<tr>
<td align="left" width="150"></td>
<td align="right" style="padding-top:10px;"><input type="submit" name="envoyer" value="Envoyer">
</td>
</tr>
</table>
</form>
Bonjour AB, merci de ta réponse rapide.
Le double <form> c'est une erreur de frappe sur le forum..
Je n'ai pas mis d'attribut action car je déclare une variable "envoyer".
Mon code avait quelques erreurs je l'ai modifié mais ça bloque toujours.
J'utilise ce formulaire pour l'inscription avec INSERT INTO et ça marche sans problème ..
Voilà la mise à jour :
Mon code UPDATE
[php]if(isset($_POST['envoyer'])){
$alerte = $_POST['envoyer'];
$id = $_POST['id'];
$email = addslashes(htmlentities($_POST['email']));
$pass = addslashes(htmlentities($_POST['pass']));
$pass2 = addslashes(htmlentities($_POST['pass2']));
$civilite = addslashes(htmlentities($_POST['civilite']));
$nom = addslashes(htmlentities($_POST['nom']));
$prenom = addslashes(htmlentities($_POST['prenom']));
$adresse = addslashes(htmlentities($_POST['adresse']));
$cp = addslashes(htmlentities($_POST['cp']));
$ville = addslashes(htmlentities($_POST['ville']));
$telephone = addslashes(htmlentities($_POST['telephone']));
$portable = addslashes(htmlentities($_POST['portable']));
$fax = addslashes(htmlentities($_POST['fax']));
if(isset($_POST['email'])&&($_POST['pass'])&&($_POST['pass2']))
{ mysql_query(" UPDATE clients SET
nom='$nom', prenom='$prenom', email='$email', telephone='$telephone', pass='$pass', civilite='$civilite', portable='$portable', cp='$cp', ville='$ville', adresse='$adresse', fax='$fax', pass2='$pass2' WHERE id='$id'") or die (mysql_error()) ;
echo '<center><p>OK mise a jour</p> </center>';
}
}[/php]
Mon formulaire avec apercu des champs deja remplis
[php]session_start() ;
if ( isset( $_SESSION['email_clients'] ) )
{
$login=$_SESSION['id_clients'];
echo '<input type="hidden" name="id" value="'.$login.'" />';
$demande2 = mysql_query("SELECT * FROM clients WHERE id=$login" ) or die (mysql_error());
while ($clients = mysql_fetch_assoc($demande2))
{
//if(isset($_POST['envoyer'])){
$id = $clients['id'];
$email = $clients['email'];
$emailverif = $clients['emailverif'];
$pass = $clients['pass'];
$civilite = $clients['civilite'];
$nom = $clients['nom'];
$prenom = $clients['prenom'];
$adresse = $clients['adresse'];
$cp = $clients['cp'];
$ville = $clients['ville'];
$telephone = $clients['telephone'];
$portable = $clients['portable'];
$fax = $clients['fax'];
?>[/php]
[code]<form method="post">
<table border="0" cellspacing="0">
<tr>
<td align="left" width="150" style="padding:10px 0 10px 0;"><b>* Identifiants</b></td>
<td> </td>
</tr>
<tr>
<td align="left" width="150">* Votre e-mail :</td>
<td><input type="text" name="email" size="20" value="<?php echo $email; ?>" /> </td>
</tr>
...
<tr>
<td align="left" width="150">Votre fax :</td>
<td><input type="text" name="fax" size="20" value="<?php echo $fax; ?>" /></td>
</tr>
<tr>
<td align="left" width="150"></td>
<td align="right" style="padding-top:10px;"><input type="submit" name="envoyer" value="Envoyer">
</td>
</tr>
</table>
</form>[/code]
[php]<?php
echo'</div>';
}}
else { echo' VOUS N\'ETES PAS AUTORISE A VOIR CETTE PAGE. VEUILLEZ VOUS CONNECTER.';}
?>[/php]
L'affichage est dans cet ordre.
Et pourtant ça marche pour une création d'un utilisateur.
Si ça peut aider, voilà mon code de création d'utilisateur:
[php]if(isset($_POST['envoyer'])){
$alerte = $_POST['envoyer'];
$id = addslashes(htmlentities($_POST['id'], ENT_NOQUOTES));
$email = addslashes(htmlentities($_POST['email'], ENT_NOQUOTES));
$pass2 = addslashes(htmlentities($_POST['pass2'], ENT_NOQUOTES));
$pass = addslashes(htmlentities($_POST['pass'], ENT_NOQUOTES));
$civilite = addslashes(htmlentities($_POST['civilite'], ENT_NOQUOTES));
$nom = addslashes(htmlentities($_POST['nom'], ENT_NOQUOTES));
$prenom = addslashes(htmlentities($_POST['prenom'], ENT_NOQUOTES));
$adresse = addslashes(htmlentities($_POST['adresse'], ENT_NOQUOTES));
$cp = addslashes(htmlentities($_POST['cp'], ENT_NOQUOTES));
$ville = addslashes(htmlentities($_POST['ville'], ENT_NOQUOTES));
$telephone = addslashes(htmlentities($_POST['telephone'], ENT_NOQUOTES));
$portable = addslashes(htmlentities($_POST['portable'], ENT_NOQUOTES));
$fax = addslashes(htmlentities($_POST['fax'], ENT_NOQUOTES));
if(isset($_POST['email'])&&($_POST['pass'])&&($_POST['pass2']))
{ $query="SELECT email FROM clients WHERE email='".$email."'";
$result=mysql_query($query);
if(mysql_num_rows($result)== 1)
{
echo '<div style="padding:5px;"><b>Cette adresse e-mail existe deja </b></div>';
}
else if(($pass)!=($pass2))
{
echo '<div style="padding:5px;"><b>Erreur dans la saisie du mot de passe </b></div>';
}
else{
$sql = "INSERT INTO clients VALUES
('$id', '$nom', '$prenom', '$email', '$elephone', '$pass', '$civilite', '$portable', '$cp', '$ville', '$adresse', '$fax', '$pass2') "; mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
}
}[/php]
le formulaire
[code]<form method="post">
<table border="0" cellspacing="0">
<tr>
<td align="left" width="150" style="padding:10px 0 10px 0;"><b>* Identifiants</b></td>
<td> </td>
</tr>
...
<tr>
<td align="left" width="150"></td>
<td align="right" style="padding-top:10px;"><input type="submit" name="envoyer" value="Envoyer">
</td>
</tr>
</table>
</form>[/code]