ปัญหาเกี่ยวกับภาษาอีกแล้วค่ะ ช่วยหน่อย จนปัญญามากเลยค่ะ
เอามาให้แล้วลองวิเคราะห์กันด้วยนะคะ ประมาณว่าจนปัญญาค่ะ อันนี้เป็น code ที่ทำทั้งหมด 3 อย่างค่ะ เมื่อ User กด Submit ข้อมูลจะเก็บใน Database และจะส่งmail หา webmaster ([email protected] ) และจะทำการส่ง Mail หา user ด้วยในตัว
และนอกจากภาษาจะเพี้ยนแล้วเมื่อส่ง Mail ยังเข้าเป็น Mail ขยะด้วยค่ะ มีวิธีแก้ไหมคะ
<?
if (isset($_POST['fname'])) {
$fname = $_POST['fname'];
} else {
$fname = "0";
}
if (isset($_POST['email'])) {
$email = $_POST['email'];
} else {
$email = "0";
}
if (isset($_POST['telephone'])) {
$telephone = $_POST['telephone'];
} else {
$telephone = "0";
}
if (isset($_POST['detail'])) {
$detail = $_POST['detail'];
} else {
$detail = "0";
}
if (isset($_POST['chk1'])) {
$contact = $_POST['chk1'];
} else {
$contact = "0";
}
if (isset($_POST['chk2'])) {
$news = $_POST['chk2'];
} else {
$news = "0";
}
include("../include/dbinfo.inc");
mysql_connect ($host, $username, $password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO register
(fname,email,telephone,detail,date,contact,news)
VALUES ('$fname','$email','$telephone','$detail','$date','$contact','$news')";
$result=mysql_query($query);
mysql_close();
$newschk1 = "ต้องการข้อมูลเพิ่มเติมให้ติดต่อกลับ";
$newschk2 = "ต้องการได้รับข่าวสารของผลิตภัณฑ์จากเรา";
if (isset($_POST['chk1'])) {
$news1 = $newschk1 ;
} else {
$newschk1 = "0";
}
if (isset($_POST['chk2'])) {
$news2 = $newschk2;
} else {
$newschk2 = "0";
}
/* recipients */
$to = "[email protected] ";
$to2="$email";
/* subject */
$subject = "ยินดีต้อนรับ";
$subject2 = "ยินดีต้อนรับ";
/* message */
$message = "
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'> // เปลี่ยนเป็น windows-874 หรือ tis-620 แล้วก็ยังไม่ได้
<title>Message</title>
</head>
<body>
<p>Note: This email was generated from web</p>
<table>
<tr>
<td>Name : $fname</td>
</tr>
<tr>
<td>Email : $email</td>
</tr>
<tr>
<td>Telephone : $telephone</td>
</tr>
<tr>
<td>Message : $detail</td>
</tr>
<tr>
<td>$news1</td>
</tr>
<tr>
<td$news2</td>
</tr>
</table>
</body>
</html>
";
/* message2 */
$message2 = "
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'> // เปลี่ยนเป็น windows-874 หรือ tis-620 แล้วก็ยังไม่ได้
<title>Thanks you</title>
</head>
<body>
<p>Note: This email was generated from web</p>
<table>
<tr>
<td>สวัสดีค่ะคุณ $fname</td>
</tr>
<tr>
<td>ข้อมูลของท่านคือ</td>
</tr>
<tr>
<td>Name : $fname</td>
</tr>
<tr>
<td>Email : $email</td>
</tr>
<tr>
<td>Telephone : $telephone</td>
</tr>
<tr>
<td>Message : $detail</td>
</tr>
<tr>
<td>$news1</td>
</tr>
<tr>
<td>$news2</td>
</tr>
<tr>
<td>ทางเราหวังเป็นอย่างยิ่งว่าจะได้รับความไว้วางใจจากท่านในการเลือกใช้ผลิตภัณฑ์ของ </td>
</tr>
<tr>
<td>ขอบคุณค่ะ</td>
</tr>
</table>
</body>
</html>
";
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=windows-874\r\n";
$headers2 = "MIME-Version: 1.0\r\n";
$headers2 .= "Content-type: text/html; charset=windows-874\r\n";
/* additional headers */
//$headers .= "To: $to\r\n";
$headers .= "From: $fname <$email>\r\n";
$headers2.= "From: nahm-sanitaryware.com";
/* and now mail it */
mail($to, $subject, $message, $headers);
mail($to2,$subject2, $message2, $headers2);
?>
$headers .= "Content-type: text/html; charset=windows-874\r\n"; /
$headers2 .= "Content-type: text/html; charset=windows-874\r\n";
ถ้าใช้เป็น windows-874 ตัวที่เป็น $fname หรืออื่น ๆ ที่รับค่ามา จะเป็นภาษาไทย แต่ ที่รับค่าของ $message และ $message2 จะเป็นเพี้ยน ถ้าเปลี่ยนเป็น utf-8 ตัวที่รับค่า $fname หรืออื่น ๆ จะเป็นภาษาเพี้ยน แต่ $message และ $message2 จะเป็นไทย
Tag : - - - -
Date :
27 พ.ค. 2551 15:00:15
By :
จนปัญญา
View :
1488
Reply :
0
Load balance : Server 01