字符编码未声明

时间:2017-01-11 16:30:35

标签: php html database

我正在使用表格通过php文件更新我的数据库,但我在 Firefox 中遇到以下错误:

  

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

Chrome 中出现以下错误:

  

为已经托管的元素调用Element.createShadowRoot()   不赞成使用影子根。看到   https://www.chromestatus.com/features/4668884095336448了解更多信息   细节

一旦我点击上面的控制台消息提交按钮,就会显示一个完整的空白页面。

我附加了我的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');


            ?>

0 个答案:

没有答案