Php 未声明字符编码

Php 未声明字符编码,php,html,database,Php,Html,Database,我正在使用表单通过php文件更新数据库,但在Firefox中出现以下错误: 未声明HTML文档的字符编码。这个 在某些浏览器配置中,文档将以乱码文本呈现 如果文档包含US-ASCII范围之外的字符。 页面的字符编码必须在文档或 在传输协议中 以及Chrome中的以下错误: 正在为已承载的元素调用Element.createShadowRoot() 不推荐使用阴影根。看见 更多 细节 单击上面控制台消息中的提交按钮后,将显示一个完整的空白页 为了更好的主意,我附上了我的html和php文件 reg

我正在使用表单通过php文件更新数据库,但在Firefox中出现以下错误:

未声明HTML文档的字符编码。这个 在某些浏览器配置中,文档将以乱码文本呈现 如果文档包含US-ASCII范围之外的字符。 页面的字符编码必须在文档或 在传输协议中

以及Chrome中的以下错误:

正在为已承载的元素调用Element.createShadowRoot() 不推荐使用阴影根。看见 更多 细节

单击上面控制台消息中的提交按钮后,将显示一个完整的空白页

为了更好的主意,我附上了我的html和php文件

register.html

    <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>

      <title> Info</title>
       <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      <meta name="viewport" content="width=device-width, initial-scale=1">


      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
      <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
      <link rel="stylesheet" href="bootstrap/css/scheduler.css">

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
      <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

    </head>

    <body>

    <div class="container container-table" >
      <div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2" >                    
                <div class="panel panel-info" style="background-color:#ccc;">
                        <div class="panel-heading"style="background-color:#990000;">
                            <div class="panel-title" style="color:white; text-align:center">Register</div>
                          <!--  <div style="float:right; font-size: 80%; position: relative; top:-10px"><a href="#">Forgot password?</a></div>-->
                        </div>     

                        <div style="padding-top:30px" class="panel-body" >

                            <div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>

                            <form action="register.php" id="loginform" class="form-horizontal" role="form" method="post">

                                <div style="margin-bottom: 20px" class="input-group">
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-education"></i></span>
                                            <input id="login-username" type="text" class="form-control" name="sbuid" value="" placeholder="SBU ID">                                        
                                        </div>
                                     <div style="margin-bottom: 20px" class="input-group">
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                                            <input id="login-username" type="text" class="form-control" name="stuName" value="" placeholder="Name">                                        
                                        </div>
                                        <div style="margin-bottom: 20px" class="input-group">
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
                                            <input id="login-username" type="text" class="form-control" name="emailID" value="" placeholder="Email ID">                                        
                                        </div>
                                         <div style="margin-bottom: 20px" class="input-group">
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-earphone"></i></span>
                                            <input id="login-username" type="text" class="form-control" name="contactInfo" value="" placeholder="Contact No.">                                        
                                        </div>
                                <div style="margin-bottom: 15px" class="input-group">
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
                                            <input id="login-password" type="password" class="form-control" name="pass" placeholder="Password">
                                        </div>





                                    <div style="margin-top:10px;text-align:center" class="form-group">
                                        <!-- Button -->

                                        <div class="col-sm-12 controls" >

                                         <input type = "submit" value= "Register" class="btn btn-success"></input>

                                        </div>
                                    </div>

                                </form>     

                                    <div style="text-align:center">
                                    <a href="index.html"><strong>Sign In </strong></a>

                                    </div>

                            </div>                     
                        </div>  
            </div>
        </div>



       <div id = "footer" class="container-fluid text-center">
            <p>INFO</p>
        </div>

    </body>

    </html>

信息
登记
信息

register.php

<?php

            $sbuidreg = isset($_POST['sbuid']) ? htmlspecialchars($_POST['sbuid']):"NA";
            $passreg = isset($_POST['pass']) ? htmlspecialchars($_POST['pass']):"NA";
            $stuNamereg = isset($_POST['stuName']) ? htmlspecialchars($_POST['stuName']):"NA";
            $emailIDreg = isset($_POST['emailID']) ? htmlspecialchars($_POST['emailID']):"NA";
            $contactInforeg = isset($_POST['contactInfo']) ? htmlspecialchars($_POST['contactInfo']):"NA";


                        $myserver = "127.0.0.1:3306"
                        $database = "tcpscheduler";
                        $password = "rootpassword";
                        $username = "root";


                        // Connect to database
                        $con = mysqli_connect($myserver, $username, $password, $database);

                                        if ($con->connect_error) {
                                            die("Connection failed: " . $con->connect_error);

                                        }



            mysqli_query($con,"INSERT INTO `loginsection` VALUES('$sbuidreg', '$passreg','$stuNamereg', '$emailIDreg','$contactInforeg')") or die("Strange Error");


            echo "Account Created";

            mysqli_close($con);

            header('Location: index.html');


            ?>

您是否尝试将此添加到html标题?是的,我也试着加上了。Safari中显示的不是错误,而是空白页。您没有指定要插入信息的任何列。请检查错误日志中与PHP相关的任何错误。@k97513您在这里指的是哪一列?我已经使用INSERT命令将信息插入数据库。