I got a php form which write fields in text files. php file is utf8 and created files are utf8 too. (for persian language I need utf8) problem: when I open created file for example: post.txt in browser, I get something like:
ªÛŒØªØ± مطلب:
لینک ØµÙØÙ‡:
آدرس تصویØ
Code
<html dir="rtl">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<title>خبررسان</title>
<style type="text/css">
.form {
font-family: Tahoma;
font-size: 11px;
}
</style>
</head>
<body class="form" style="margin: 0">
<?php
if($_POST['Submit'])
{
$title = $_POST['title'];
$link = $_POST['link'];
$image = $_POST['image'];
$post = $_POST['post'];
$postid = rand(0, 999999999);
//open the file and choose the mode
$fh = fopen("last.txt", "w");
fwrite($fh, $postid);
//close the file
fclose($fh);
//open the file and choose the mode
$fh = fopen("title.txt", "w");
fwrite($fh, $title);
//close the file
fclose($fh);
//open the file and choose the mode
$fh = fopen("link.txt", "w");
fwrite($fh, $link);
//close the file
fclose($fh);
//open the file and choose the mode
$fh = fopen("image.txt", "w");
fwrite($fh, $image);
//close the file
fclose($fh);
//open the file and choose the mode
$fh = fopen("post.txt", "w");
fwrite($fh, $post);
//close the file
fclose($fh);
header("Location:index.php");
}
else
{
print <<<ENDOFTXT
</style><form name="form1" method="post" action="index.php">
<table border="0" align="center">
<tr>
<td><span class="style5">تیتر مطلب:</span></td>
<td><input name="title" type="text" id="title" style="font-family: tahoma"></td>
</tr>
<tr>
<td><span class="style5">لینک صفحه:</span></td>
<td><input name="link" type="text" id="link" value="" style="font-family: tahoma"></td>
</tr>
<tr>
<td><span class="style5">آدرس تصویر:</span></td>
<td><input name="image" type="text" id="image" style="font-family: tahoma"></td>
</tr>
<tr>
<td><span class="style5">مطلب:</span></td>
<td><textarea name="post" id="post" rows="5" cols="30" style="font-family: tahoma"></textarea></td>
</tr>
<tr>
<td><input name="Submit" type="submit" class="style5" value="ارسال مطلب به مخاطبین من" style="font-family: tahoma"></td>
</tr>
<tr>
<td colspan="2"><div align="center"></div></td>
</tr>
</table>
<p align="center"> </p>
</form>
ENDOFTXT;
}
?>
</body>
</html>