php数据库乱码问题

php将数据上传到数据库,但是出现了乱码,怎么也改不好了,下面是我的代码看了一下网上解决办法,都没啥用哎。



session_start();header( "Content-type:text/html;charset=utf-8" );
$link = mysqli_connect( 'xxxxxxxx' , 'xxxx' , 'xxxxxx' , 'test' );
  
if (! $link ) {
  die ( "连接失败:" .mysqli_connect_error());
}
$username = $_POST [ 'username' ];
$email = $_POST [ 'email' ];
if ( $username == ""  || $email == "" )
{
  echo "" ;
} elseif (( strlen ( $username ) < 1)) {
  echo "" ;
  //判断用户名长度
} 
 elseif (mysqli_fetch_array(mysqli_query( $link, "set names utf8","select * from login where username = '$username'" ))){
  echo "" ;
} else {
  $sql = "insert into login(username, email)values('$username','$email')" ;
  if (!(mysqli_query( $link , $sql))){
    echo "" ;
  } else {
    echo "" ;
  }
}
?>
html>
<html>
<head>
   <title>留言title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   <style type= "text/css" >
     *{margin:0px;padding:0px;}
     ul{
       width:400px;
       list-style:none;
       margin:50px auto;
     }
     li{
       padding:12px;
       position:relative;
     }
     label{
       width:155px;
       display:inline-block;
       float:left;
       line-height:30px;
     }
     input[type= 'text' ],input[type= 'password' ]{
       height:30px;
     }
     img{
       margin-left:10px;
     }
     input[type= "submit" ]{
       margin-left:80px;
       padding:5px 10px;
     }
   style>
head>
<body>
 <h1>待更新h1>
<video width="320" height="240" controls autoplay loop>  
  <source src="1.mp4" type="video/mp4">  
  Your browser does not support the html video tag.  
video>
<form action= "zhuce.php" method= "post" >
   <ul>
     <li>
       <label>留下您尊贵的大名:label>
       <input type= "text" name= "username" placeholder= "请输入" />
     li>

     <li>
       <label>留言:label>
       <input type= "text" name= "email" placeholder= "请输入" />
     li>
     <li>
       <input type= "submit" value= "提交" />
     li>
   ul>
form>
body>
html>

img

img