Page 1 of 1
phpmailer contact form special characters
Posted: Mon Mar 02, 2015 2:07 pm
by terrenuit
Hi,
I have a contact form which cannot receive the special characters(à, ù, €....)
somebody knows how to do ?
thanks
Re: phpmailer contact form special characters
Posted: Mon Mar 02, 2015 2:29 pm
by Celauran
How do you mean? What happens when someone enters accented characters?
Re: phpmailer contact form special characters
Posted: Tue Mar 03, 2015 1:54 am
by terrenuit
when someone send message 100€,
je receive 100???
same for à, é.....
Re: phpmailer contact form special characters
Posted: Tue Mar 03, 2015 1:55 am
by terrenuit
when someone send message 100€,
je receive 100???
same for à, é.....
Re: phpmailer contact form special characters
Posted: Tue Mar 03, 2015 6:18 am
by Celauran
Sounds like a character encoding issue. Are you using UTF-8 everywhere?
Re: phpmailer contact form special characters
Posted: Tue Mar 03, 2015 2:33 pm
by terrenuit
yes, I put utf-8 everywherre, no problem for send/receive message, only the special characters(€,à,é....) become the wrong codes (????)
it is my script:
index;php
Code: Select all
<?php
$s=$_GET['s'];
if ($s=="1") {
echo ('<span class="success">Your message has been sent, we treat it quickly and get back to you asap! </span>');
}
else if ($s=="2") {
echo ('<span class="fail">Error! Please refill again </span>');
}
?>
<form action="send_en.php" method="post">
<table width="486" border="0" cellspacing="4" cellpadding="0">
<tr>
<td width="152"><div id="fond">Title:</div></td>
<td width="334"><input type="radio" name="likeit" value="mademoiselle" checked="checked" />
Miss
<input type="radio" name="likeit" value="madame" />
Mrs
<input type="radio" name="likeit" value="monsieur" />
Mr
</td>
</tr>
<tr>
<td><b>Your full name:</b></td>
<td><input type="text" name="yourname" size="40" /></td>
</tr>
<tr>
<td><b>Subject:</b></td>
<td><input type="text" name="subject" size="40" /></td>
</tr>
<tr>
<td><b>E-mail:</b></td>
<td><input type="text" name="email" size="40" /></td>
</tr>
<tr>
<td><b>Message:</b></td>
<td><textarea name="adresse" cols="40" rows="10" id="adresse" label="Message:"></textarea></td>
</tr>
<tr>
<td>Anti spam:
9+1=</td>
<td><input name="secu" type="text" id="secu" size="6"></td>
</tr>
</table>
<p><input type="submit" value="Send!"></p>
</form>
send-en.php
Code: Select all
<?php
/* Set e-mail recipient */
$myemail = "abcd@gmail.com";
/* Check all form inputs using check_input function */
$yourname = check_input($_POST['yourname'], "Enter your name");
$subject = check_input($_POST['subject'], "Write a subject");
$email = check_input($_POST['email'], "Please fill your email");
$website = check_input($_POST['website']);
$secu = check_input($_POST['secu']);
$likeit = check_input($_POST['likeit']);
$how_find = check_input($_POST['how']);
$adresse = check_input($_POST['adresse'], "Write your comments");
/* Let's prepare the message for the e-mail */
$message = "New Message!
$likeit
Name: $yourname
E-mail: $email
Subjet: $subject
Message:$adresse
$how_find
End of message
";
if ($secu=="10") {
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header("Location:contact_en.php?s=1");
}
else {
header("Location:contact_en.php?s=2");
}
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
?>