phpmailer contact form special characters

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
terrenuit
Forum Commoner
Posts: 53
Joined: Tue Jul 08, 2014 2:18 pm

phpmailer contact form special characters

Post by terrenuit »

Hi,
I have a contact form which cannot receive the special characters(à, ù, €....)
somebody knows how to do ?
thanks
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: phpmailer contact form special characters

Post by Celauran »

How do you mean? What happens when someone enters accented characters?
terrenuit
Forum Commoner
Posts: 53
Joined: Tue Jul 08, 2014 2:18 pm

Re: phpmailer contact form special characters

Post by terrenuit »

when someone send message 100€,
je receive 100???
same for à, é.....
terrenuit
Forum Commoner
Posts: 53
Joined: Tue Jul 08, 2014 2:18 pm

Re: phpmailer contact form special characters

Post by terrenuit »

when someone send message 100€,
je receive 100???
same for à, é.....
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: phpmailer contact form special characters

Post by Celauran »

Sounds like a character encoding issue. Are you using UTF-8 everywhere?
terrenuit
Forum Commoner
Posts: 53
Joined: Tue Jul 08, 2014 2:18 pm

Re: phpmailer contact form special characters

Post 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;
}

?>
Post Reply