no save
Assistance
Achat
News

Forum | webmastering
problème d'encodage de données de formulaire
a.finot, le sam. 27 juin 2009 à 19:18:58
Bonjour,
J'ai un formulaire d'inscription qui envoie des données dans une base mysql mais les données sont enregistrées en html, donc sans les accents... ma base est codée en utf8.
Je voudrais utiliser la fonction html_entity_decode mais je ne sais pas où la placer. Ca fait des heures que je cherche et après des tas d'essais je ne trouve pas ;-(
Si quelqu'un a la soluce, je suis preneuse !
Merci d'avance.

Voici le code :
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "contacts")) {
$insertSQL = sprintf("INSERT INTO clients (ID, nom, prenom, email, tel, adresse, cp, ville, pays, `index`, niveau) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ID'], "int"),
GetSQLValueString($_POST['nom'], "text"),
GetSQLValueString($_POST['prenom'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['tel'], "text"),
GetSQLValueString($_POST['adresse'], "text"),
GetSQLValueString($_POST['cp'], "text"),
GetSQLValueString($_POST['ville'], "text"),
GetSQLValueString($_POST['pays'], "text"),
GetSQLValueString($_POST['index'], "text"),
GetSQLValueString($_POST['niveau'], "text"));

mysql_select_db($database_lcdvs, $lcdvs);
$Result1 = mysql_query($insertSQL, $lcdvs) or die(mysql_error());

$insertGoTo = "home.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<div id="formulairecontact">
<form action="<?php echo $editFormAction; ?>" name="contacts" id="contacts" method="POST""http://www.lesclefsdevotreswing.com/envoimail.php">
<table width="610" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="311" height="27">Nom :
<input name="nom" type="text" id="nom" size="35" /></td>
<td width="299">Prénom :
<input name="prenom" type="text" id="prenom" size="35" /></td>
</tr>
<tr>
<td><p>Adresse :
<input name="adresse" type="text" id="adresse" size="35" />
</p> </td>
<td>Pays :
<input name="pays" type="text" id="pays" size="35" /></td>
</tr>
<tr>
<td>Code postal :
<input name="cp" type="text" id="cp" size="35" /></td>
<td>Ville :
<input name="ville" type="text" id="ville" size="35" /></td>
</tr>
<tr>
<td>Email :
<input name="email" type="text" id="email" size="35" /></td>
<td>Mobile :
<input name="tel" type="text" id="tel" size="35" /></td>
</tr>
<tr>
<td>Index :
<input name="index" type="text" id="index" size="35" /></td>
<td>Si vous n'êtes pas classé, merci de nous indiquer votre niveau :
<select name="niveau" id="niveau">
<option value="Classé">Classé</option>
<option value="Non initié">Non initié</option>
<option value="Débutant">Débutant</option>
<option value="Carte verte">Carte verte</option>
<option value="Moyen">Moyen</option>
</select></td>
</tr>
<tr>
<td><input type="hidden" name="ID" id="ID" /></td>
<td><input type="submit" name="envoyer" id="envoyer" value="Validez votre inscription" /></td>
</tr>
</table>

<input type="hidden" name="MM_insert" value="contacts" />
</form>
</div>Configuration: Windows XP Internet Explorer 7.0


a.finot
29 juin
Suivant
REPONSES
a.finot
29 juin
enox
29 juin
a.finot
29 juin
enox
29 juin
a.finot
29 juin
enox
29 juin
a.finot
29 juin
enox
30 juin
Version Web
Réalisé par RedShift
no save