Problem with encoding in PHP

Discussion in 'PHP' started by Matt18, Nov 11, 2011.

  1. #1
    Hi

    I am using this script to send mail:

    <?php
    if (isset($_GET['email']))
      {
      //send email
      $email = $_GET['email'] ;
      $subject = $_GET['subject'] ;
      $message = $_GET['message'] ;
      mail("@gmail.com", "$subject",
      $message, "From:" . $email);
      echo "Coolčćžš!";
      }
    ?>
    
    
    <div id="contactus" >
    <form method="get" action="http://...">
      Email: <input name="email" type="text" /><br />
      Subject: <input name="subject" type="text" /><br />
      Message:<br />
      <textarea name="message" rows="15" cols="40">
      </textarea><br />
      <input class="highlight_input_btn fr" type="submit" value="Send" />
      </form>
    </div>
    PHP:
    Charset in the e-mail is somehow ok. But the echo statement on success does not show chars čćžš. Can someone help me out please?

    Thank you very much in advance!
     
    Matt18, Nov 11, 2011 IP
  2. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #2
    Have you tried something like this?

    
    echo utf8_encode('Coolčćžš!');
    
    PHP:
     
    stephan2307, Nov 11, 2011 IP
  3. Matt18

    Matt18 Guest

    Messages:
    591
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This removes the chars.. Before it replaced them with "?"

    Any other suggestions? Thank you!
     
    Matt18, Nov 11, 2011 IP
  4. avinash gaud

    avinash gaud Member

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    2
    Trophy Points:
    26
    #4
    Hello,

    Try this

    Open the file in notepad++ then from menu toolbar select encoding in encoding select convert to UTF-8 and then save the file.
     
    avinash gaud, Nov 11, 2011 IP
  5. Matt18

    Matt18 Guest

    Messages:
    591
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That didn't help either, but I replaced the text so I don't need this characters.

    Thank you all for help! :)
     
    Matt18, Nov 16, 2011 IP