0

How set unicode utf-8 to this scipt mass mail sender

HTML:

<form action="sendemail.php" method="post">
<label>Subject of email:</label><br><input type="text" name="subject" id="subject"/><br>
<label>Body of email:</label><br><textarea name="body" id="body" rows="10" cols="70"></textarea><br>
<input type="submit" name=submit value="Submit"/>
</form>

PHP:

<?php

$user = "user_name"; 
$password = "password"; 
$host = "host_name"; 
$dbase = "database_name"; 
$table = "table_name"; 

$from= 'email_address';

$subject= $_POST['subject'];
$body= $_POST['body'];

$dbc= mysqli_connect($host,$user,$password, $dbase) 
or die("Unable to select database");

$query= "SELECT * FROM $table";
$result= mysqli_query ($dbc, $query) 
or die ('Error querying database.');

while ($row = mysqli_fetch_array($result)) {
$first_name= $row['first_name'];
$last_name= $row['last_name'];
$email= $row['email'];
$msg= "Dear $first_name $last_name,\n$body";
mail($email, $subject, $msg, 'From:' . $from);
echo 'Email sent to: ' . $to. '<br>';
}
mysqli_close($dbc);
?>

$last_name is ėkovič, show mail letter - ?kovi?

p.s. set character_set_client='utf8'

set collation_connection='utf8_general_ci' not work.

1 Answers1

0

You need to set character encoding to get the same

set character_set_client='utf8'

set collation_connection='utf8_general_ci'

See Here for more information on Character Set and Collation for Applications

You should also see this post How to display Unicode data with PHP

Community
  • 1
  • 1
Rahul
  • 76,197
  • 13
  • 71
  • 125
  • @user3708534, that can't be. you need to set them in your PHP code before calling the `select` command. Also, go through the links in my answer. 1. `mysql_query ("set character_set_results='utf8'")` 2. `select * from table`. this should work. – Rahul Jun 06 '14 at 20:40
  • @user3708534, don't forget to accept the answer by clicking the check button under voting button if it helped. – Rahul Jun 06 '14 at 21:08
  • i use $dbc->set_charset('utf8') and is help me. – user3708534 Jun 07 '14 at 11:16
  • @user3708534, sounds great; also; along with whatever I have mentioned in my answer; try setting your page `encoding-type` to `utf-8` by saying `` – Rahul Jun 07 '14 at 11:18