PHP字符编码问题

时间:2016-02-16 00:11:09

标签: php html mysql utf-8

我添加了我的代码。当我在文本框中输入一些“öçşi”字符时。在phpmyadmin中显示为“öþðýç”。我设置了utf-8 general_ic。并在我的html文件中添加了“”。我怎么解决这个问题?抱歉我的英语不好。

add_info.php

<?php
header('Content-Type: text/html; charset=utf-8');

require "init.php";
$dizi = $_POST["dizi"];
$kanal = $_POST["kanal"];
$sure = $_POST["sure"];



$sql = "insert into diziler values('$dizi', '$kanal', '$sure');";



if(mysqli_query($con,$sql)){
 echo "<br><h3>Dizi Eklendi</h3>";
}else{
 echo "Ekleme Hatasi " . mysqli_error($con);
}

?>

的index.php

<html>
<head>
<title>Add Thing</title>
<meta HTTP-EQUIV="Content-type" VALUE="text/html; charset=utf-8" />

<body>
  <form action = "add_info.php" method="post">
    <table>
      <tr>
          <td>Dizi: </td>
      <td><input type="text" name = "dizi" /></td>
  </tr>
  <tr>
      <td>Kanal: </td>
      <td><input type="text" name = "kanal" /></td>
  </tr>
  <tr>
      <td>Süre: </td>
      <td><input type="text" name = "sure" /></td>
  </tr>
</table>

的init.php

<?php
header('Content-Type: text/html; charset=utf-8');

$host = "localhost";
$user = "h4yfans";
$pass = "6288730";
$db = "butundiziler";


 $con = mysqli_connect($host,$user,$pass,$db);

if(!$con){
    die("Baglanti Hatasi ".mysqli_connect_error());

}
else{
    echo "<br><h3>Baglanildi</h3>";
}
?>

0 个答案:

没有答案