SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can't get special characters working (php mail contact form)

    Hi,

    I've tried many things, but don't have any clue what could be wrong with code. Special characters are not showing in Thunderbird on computer, but are showing in hotmail/gmail. Here's the complete code I use:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <META HTTP-EQUIV="refresh" content="0;URL=thank-you-for-message.html">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Thank you for your message</title>
    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    
      ga('create', 'UA-XXXXXXXX-X', 'domain.com');
      ga('send', 'pageview');
    
    </script>
    </head>
    <body>
    <?php
    iconv_set_encoding("internal_encoding", "utf-8");
    $name = $_POST['nameSurname'];
    $address = $_POST['address'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $how = $_POST['how'];
    $subject = $_POST['subjectcontent'];
    $message = $_POST['message'];
    
    $to  = 'some@email.com' . ', ';
    $subject = "".$subjectcontent."";
    $message = "THIS MESSAGE IS SENT FROM ONLINE CONTACT FORM\n"
                ."-------------------------------------------------------------------------------------------\n"
                ."\n"
    						."NAME:\n"
                .$name."\n"
                ."\n"
                ."FULL ADDRESS:\n"
    						.$address."\n"
    						."\n"
    						."E-MAIL:\n"
    						.$email."\n"
    						."\n"
    			      ."PHONE:\n"
    						.$phone."\n"
    						."\n"
    			      ."YOU MAY CONTACT ME:\n"
    						.$how."\n"
    						."\n"
                ."MESSAGE:\n"
                .$message. ;
    
    $headers  = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=utf-8" . "\r\n";
    $headers .= "Content-Transfer-Encoding: 8bit\n";
    $headers = "From:" .$email. "\r\n";
    						
    mail($to,$subject,$message,$headers);
    ?> 
    </body>
    </html>
    I've tried so many things that I don't know anymore what I've tired. It's really start getting very annoying, as I can't find any solution for this.

    Kind regards

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,316
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by ninostar View Post
    Special characters are not showing in Thunderbird
    Could you give some more information? What special characters are you talking about?

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm talking about special characters ČŽŠčćžšđ (German, Italian, Croatian)...

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,316
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by ninostar View Post
    I'm talking about special characters ČŽŠčćžšđ (German, Italian, Croatian)...
    I don't see those characters in your code. That's not what I meant by more information. Where are you trying to use these characters, and how, and all that ?

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've translated some text in the code and I use this form in four different languages (they are in different folders - EN/DE/IT/HR). I've have contact form on html page, when user clicks on send button, data is sent to send-email.php file (the code that I've published above) and then that page redirects user to "thank you for your message" page. Most special characters are entered into the form when filling out the contact form on website. Users enter special characters of three languages (German, Croatian and Italian) - some of these are: ČŽŠčćžšđ.

    I hope you got enough information now...

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sadly I still didn't find any solution... I would just like to add that I don't use MySql to store messages.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •