Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 26/01/2012, 17h59   #1
Invité de passage
 
Homme
Inscription : juin 2011
Messages : 12
Détails du profil
Informations personnelles :
Sexe : Homme

Informations forums :
Inscription : juin 2011
Messages : 12
Points : 2
Points : 2
Par défaut Accent non pris en compte BDD

Bonjour,

Je suis en train de réaliser un site pour un projet à l'école mais je rencontre un gros problème avec ma base de donnée.

Je travaille avec Wamp.

Je vais prendre un exemple avec mon formulaire d’inscription depuis mon site, si je mets des accents, ils ne sont pas pris en compte.

Structure de ma table : http://img215.imageshack.us/img215/7049/tableho.jpg
Les champs : http://img717.imageshack.us/img717/8182/champsb.jpg

Mon site est pourtant encodé en utf8.

Merci d'avance pour votre aide.

Config de phpMyAdmin : http://img15.imageshack.us/img15/7964/wampz.jpg
aalex57 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/01/2012, 18h14   #2
Membre éclairé
 
Avatar de keaton7
 
Inscription : octobre 2007
Messages : 676
Détails du profil
Informations forums :
Inscription : octobre 2007
Messages : 676
Points : 320
Points : 320
Bonjour,

A tout hasard, es tu sûr que ton phpMyAdmin est convenablement configuré en UTF-8 ?
__________________
Spécialité : Développement WEB
Indispensables : Doc PHP ~ Doc MySQL ~ w3schools ~ validateurs W3C ~ Google Adwords

keaton7 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/01/2012, 18h16   #3
Membre éclairé
 
Avatar de humitake
 
Homme Olivier
Étudiant
Inscription : novembre 2010
Messages : 303
Détails du profil
Informations personnelles :
Nom : Homme Olivier
Âge : 20
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : novembre 2010
Messages : 303
Points : 384
Points : 384
Bonsoir,

Citation:
Envoyé par aalex57
si je mets des accents, ils ne sont pas pris en compte.
Le traitement du formulaire se fait-il sur la même page ?

Si ce n'est pas le cas, cela peut être résolu en utilisant urlencode() et urldecode().
Je pense que c'est le même problème pour l'espace.


Sinon si tu pouvais poster le code correspondant ce serrait plus simple pour t'aider
humitake est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/01/2012, 18h27   #4
Invité de passage
 
Homme
Inscription : juin 2011
Messages : 12
Détails du profil
Informations personnelles :
Sexe : Homme

Informations forums :
Inscription : juin 2011
Messages : 12
Points : 2
Points : 2
Bonjour,

Voici mon code :

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
<?php 
// connexionbdd();
 
$bdd = new  PDO('mysql:host=localhost;dbname=vente', 'root', '');
 
$erreur = NULL;
 
 
 
 
 
 
 
if(isset($_POST['validation'])){
 
 
 
	if (!empty ($_POST['nom']) && !empty ($_POST['prenom']) && !empty ($_POST['pseudo']) && !empty ($_POST['mdp']) && !empty ($_POST['adresse']) && !empty ($_POST['localite']) && !empty ($_POST['mail']) && (preg_match("#^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]{2,}\.[a-z]{2,4}$#", $_POST['mail'])) )
 
	{	
 
$insert = $bdd->prepare('INSERT INTO client (nom_cl,prenom_cl,adresse_cl,localite_cl,num_tel_cl,adress_mail_cl,login_cl,mdp_cl) VALUES (:nom, :prenom, :adresse, :localite, :num, :adressemail, :login, :mdp)');
$insert->bindValue(':nom', $_POST['nom'], PDO::PARAM_STR);
$insert->bindValue(':prenom', $_POST['prenom'], PDO::PARAM_STR);
$insert->bindValue(':adresse', $_POST['adresse'], PDO::PARAM_STR);
$insert->bindValue(':localite', $_POST['localite'], PDO::PARAM_STR);
$insert->bindValue(':num',$_POST['tel'], PDO::PARAM_STR);
$insert->bindValue(':adressemail', $_POST['mail'], PDO::PARAM_STR);
$insert->bindValue(':login', $_POST['pseudo'], PDO::PARAM_STR);
$insert->bindValue(':mdp', md5($_POST['mdp']), PDO::PARAM_STR);
$insert->execute();
$insert->closeCursor();
 
$_SESSION['pseudo'] = array();
$_SESSION['nom'] = array();
$_SESSION['prenom'] = array();
 
 
$_SESSION['pseudo'] = $_POST['pseudo'];
$_SESSION['nom'] = $_POST['nom'];
$_SESSION['prenom'] = $_POST['prenom'];
 
 
 
echo '<img src="img/ok.png" width="20" height="20" alt="ok" /> Inscription réussit,'.$_POST['pseudo'].' merci !<br />
Vous allez être redirigé vers votre espace <a href="compte2.php">membre</a> dans 2 secondes.';
echo '<meta http-equiv="refresh" content=2;url=compte2.php>';
 
	}
	else {
	echo '<img src="img/warning.png" width="20" height="20" alt="attention" /> Veuillez remplir les champs requits , merci.'; 
 
	if (!preg_match("#^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]{2,}\.[a-z]{2,4}$#", $_POST['mail']))
	{
		echo '<br /><img src="img/warning.png" width="20" height="20" alt="attention" /> Adresse e-mail non valide !';
	}
 
 
 
 
 
 
}
 
	} //else
 
else {
 
} // if isset validation


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
<form action="inscription.php" method="post">
 
  <fieldset>
      <legend> Informations personnelles</legend>      <br />
 
 <label><span class="attention">*</span>Nom :
   <span class="small">Veuillez entrer votre nom.</span></label>
        <input name="nom" type="text" >
 
    <label><span class="attention">*</span>Pr&eacute;nom :
    <span class="small">Veuillez entrer votre prénom.</span></label>
        <input name="prenom" type="text">
 
  <label><span class="attention">*</span>Adresse :
  <span class="small">Veuillez entrer votre adresse.</span></label>
        <input type="text" name="adresse">
 
<label><span class="attention">*</span>Localit&eacute; :
<span class="small">Veuillez entrer votre ville.</span></label>
<input name="localite" type="text" >
 
<label>Num. t&eacute;l&eacute;phone:
<span class="small">Vous pouvez entrer votre numéro de téléphone.</span></label>
<input name="tel" type="text" >
 
  <label><span class="attention">*</span>Adresse email :
  <span class="small">Veuillez entrer une adresse e-mail valide.</span></label>
      <input name="mail" type="text"  />
 
    </fieldset>
 
    <fieldset> 
    <legend> Votre compte</legend>      <br />
 
       <label for="pseudo"><span class="attention">*</span>Pseudo :
       <span class="small">Veuillez entrer un pseudo.</span></label>
        <input type="text" name="pseudo">
 
<label for="mdp"><span class="attention">*</span>Mot de passe:
<span class="small">Veuillez entrer votre mot de passe.</span></label>
        <input type="password" name="mdp" >
 
<br />
 
    			<div class="submit">
 
     <input type="submit" value="Valider l'inscription" name="validation" />
 
 
      <input  type="reset"  value="Rétablir"></div>
 
    </fieldset>
 
  </form>
aalex57 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/01/2012, 18h28   #5
Invité de passage
 
Homme
Inscription : juin 2011
Messages : 12
Détails du profil
Informations personnelles :
Sexe : Homme

Informations forums :
Inscription : juin 2011
Messages : 12
Points : 2
Points : 2
@keaton7 :Oui oui, en jeu de caractères j'ai UTF-8 Unicode .

@humitake : Le traitement ce fait sur la même page :/




Mon erreur d'espace viens d'être corrigée, j'avais oublié des " " dans mes input...

Par contre j'ai toujours mes erreurs d'accent :/
aalex57 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/01/2012, 20h30   #6
Invité de passage
 
Homme
Inscription : juin 2011
Messages : 12
Détails du profil
Informations personnelles :
Sexe : Homme

Informations forums :
Inscription : juin 2011
Messages : 12
Points : 2
Points : 2
Tout est résolu, c'est bon !
aalex57 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/01/2012, 10h10   #7
Membre éclairé
 
Avatar de keaton7
 
Inscription : octobre 2007
Messages : 676
Détails du profil
Informations forums :
Inscription : octobre 2007
Messages : 676
Points : 320
Points : 320
Juste une petite précision, attention, phpMyAdmin est un "site web", il faut donc être vigilant aux caractères qu'il affiche, qui n'ont rien à voir avec le jeu de caractères de tes tables. Tu peux ainsi avoir l'impression que tes caractères sont cassés dans ta base, alors que c'est juste ton navigateur qui les déforme
__________________
Spécialité : Développement WEB
Indispensables : Doc PHP ~ Doc MySQL ~ w3schools ~ validateurs W3C ~ Google Adwords

keaton7 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 20h41.


 
 
 
 
Partenaires

Hébergement Web