为什么我的登录页一直显示登录失败?

注册页:

<?php
    if(isset($_POST['zh'])){
        $conn=mysqli_connect('localhost:3310','root','root','list');
        $sql="select * from user where zh='{$_POST['zh']}'";
        $res=mysqli_query($conn,$sql);
        if(mysqli_num_rows($res)==0){
        $sql="insert into user(zh,pw,email) values('".$_POST['zh']."','".Md5($_POST['mm'])."','".$_POST['email']."');";
        mysqli_query($conn,$sql);
          $sql="select * from user where zh='{$_POST['zh']}'";
          $res=mysqli_query($conn,$sql);
        if(mysqli_num_rows($res)==0){
            echo"<script>alert('注册不成功!请重新注册');</script>";
        }else{
          echo"<div>注册成功,请<a href='./login.php'>登陆。</a>";
          exit;
}
           }else{
             echo"<script>alert('该账号已存在,请换个名重新尝试');</script>";
           }
           }
?>
<!doctype html>
<html>
  <head>
    <title>注册页面</title>
    <meta charset='utf-8'>
    <style>
      .sheet{width:300px;margin:30px auto;}
      label{width:40px;}
      input{width:160;}
    </style>
  </head>
  <body style="text-align:center;">
    <form action='zhuce.php' method='post'>
      <h1>欢迎注册</h1>

      <label>用户名:</label><input type='text' name='zh'><br/>
      <label>密&nbsp;码:</label><input type='password' name='mm'><br/>
      <label>邮&nbsp;箱:</label><input type='sheet' name='email'><br/>
      <div style="width:100px; margin:0 auto; text-align:left;"><input type='submit' value='注册'></div>
      <div>如果已有账号,请<a href="./login.php">登陆</a><div>
    </form>


  </body>
</html>

登录页:

<?php
    session_start();
     if(isset($_SESSION['user'])){
      header('Location:./index.php');
     }else if(isset($_POST['zh'])){
       if($_POST['yzm']==$_SESSION['yzm']){
         //预编译
         $conn=new PDO("mysql:host=localhost:3310;dbname=list","root","root");//连接数据库,返回连接对象
         $conn->exec("set names 'utf8'");
         $sql="select * from user where zh=? and pw=?";
         $com= $conn->prepare($sql);
         $com->execute(array($_POST['zh'],md5($_POST['mm'])));
         $row=$com->fetch(PDO::FETCH_ASSOC);//php对数据库返回的数据做格式转换
         if(isset($row['id'])){
           session_start();//打开session文件
           $_SESSION['user']=$row['zh'];
           header('Location:./index.php');
           }else{echo "登录失败"; exit;}
       }else{
         echo "<script>alert('验证码错误,请重新输入')</script>";
       }
     }


?>
<!doctype html>
<html>
  <head>
    <title>登陆</title>
    <meta charset='utf-8'>

  </head>
      <body style="width:200px; margin:0 auto; text-align:left;">
        <form action='login.php' method='post'>
            <h1>欢迎登录</h1>
            <label>用户名:</label>
                <input type='text' name='zh'>
                     <br/>
            <label>密&nbsp码:</label>
                <input type='password' name='mm'>
                     <br/>
          <label>验证码:</label><input type='code' name='yzm'><?php $yzm=rand(1,1000);$_SESSION['yzm']=$yzm;echo $yzm;?><br/>
                <div style="width:100px; margin:0 auto; text-align:left;"><input type='submit' value='登录'></div>
                 <a href='zhuce.php'>账号注册</a>
        </form>

  </body>
</html>

z主要是我在另外一个实验平台可以完全通过,但换成了SUBMLINE就不行了,而且我也用了var_jump查过了,明明都赋值上了可是就是显示登录失败。

可能带有前后空格,你去掉试试。你也可以f12看看请求参数和参数值。