doutao5419 2016-08-16 22:18
浏览 68
已采纳

在localhost中执行代码时,php文件中的部分html文件不会出现

I'm creating a regitration page which includes php,html and css in bootstrap.Here is my php file.

<?php include "header.php"; ?>
<html>

<head></head>

<body>
  <!--content-->
  <div class=" container">
    <div class=" register">
      <h1>Register</h1>

      <?php if(isset($_GET[ 'error'])) { echo '<font color="red">'.$_GET[ 'error']. '</font>'; echo '<br><br>'; } if(isset($_GET[ 'ok'])) { echo '<font color="blue">You are successfully Registered..</font>'; echo '<br><br>'; } ?>


      <form action="process_register1.php" method="POST">
    </div>
    <div class="col-md-6 register-bottom-grid">
      <h3>Personal infomation</h3>
      <div>
        <span>Full Name</span>
        <input type="text" size="30" maxlength="30" name='fnm'>
      </div>
      <div>
        <span>Username</span>
        <input type="text" size="30" maxlength="30" name='unm'>
      </div>
      <div>
        <span>Password</span>
        <input type='password' name='pwd' size="30">
      </div>
      <div>
        <span> Confirm password</span>
        <input type='password' name='cpwd' size="30">
      </div>
      <div>
        <span> Gender</span>
        <input type="radio" value="Female" name="gender" id='f'>Female
        <input type="radio" value="Male" name="gender" id='m'>Male
      </div>
      <div>
        <span>E-mail address</span>
        <input type='mail' name='mail' size="30">
      </div>
      <div>
        <span> No contact</span>
        <input type="text" name='contact' size="30">
      </div>
      <div>
        <span> City</span>
        <select style="width: 195px;" name="city">

          <option>Tirana</option>
          <option>Korca</option>
          <option>Vlora</option>
          <option>Kavaja</option>



        </select>
      </div>


      <input type="submit" value="submit">


    </div>

    <div class="clearfix"></div>
    </form>
  </div>
  </div>

</body>

</html>

Here is my header.php file:

<?php session_start(); require( 'config.php'); ?>
<!DOCTYPE html>
<html>

<head>
  <title>Online Shopping</title>
  <link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
  <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  <script src="js/jquery.min.js"></script>
  <!-- Custom Theme files -->
  <!--theme-style-->
  <link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
  <!--//theme-style-->
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="keywords" content="New Store Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template, 
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
  <script type="application/x-javascript">
    addEventListener("load", function() {
      setTimeout(hideURLbar, 0);
    }, false);

    function hideURLbar() {
      window.scrollTo(0, 1);
    }
  </script>
  <!--fonts-->
  <link href='http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900' rel='stylesheet' type='text/css'>
  <link href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900' rel='stylesheet' type='text/css'>
  <!--//fonts-->
  <!-- start menu -->
  <link href="css/memenu.css" rel="stylesheet" type="text/css" media="all" />
  <script type="text/javascript" src="js/memenu.js"></script>
  <script>
    $(document).ready(function() {
      $(".memenu").memenu();
    });
  </script>
  <script src="js/simpleCart.min.js">
  </script>
</head>

<body>
  <!--header-->
  <div class="header">
    <div class="header-top">
      <div class="container">
        <div class="search">
          <form>
            <input type="text" value="Search " onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Search';}">
            <input type="submit" value="Go">
          </form>
        </div>
        <div class="header-left">
          <?php if(isset($_SESSION[ 'status'])) { echo '<ul><li><a href="logout.php">Logout</a></li></ul>'; } else { echo '<ul>
                        <li ><a href="login1.php"  >Login</a></li>
                        <li><a  href="register.php"  >Register</a></li>

                    </ul>'; } ?>

          <div class="cart box_1">
            <a href="checkout.html">
              <h3> <div class="total">
                            <span class="simpleCart_total"></span> (<span id="simpleCart_quantity" class="simpleCart_quantity"></span> items)</div>
                            <img src="images/cart.png" alt=""/></h3>
            </a>
            <p><a href="javascript:;" class="simpleCart_empty">Empty Cart</a>
            </p>

          </div>
          <div class="clearfix"></div>
        </div>
        <div class="clearfix"></div>
      </div>
    </div>
    <div class="container">
      <div class="head-top">
        <div class="logo">
          <a href="index.html">
            <img src="images/logo.png" alt="">
          </a>
        </div>
        <div>
          <h1 class="title">Welcome 
                            <?php 
                                if(isset($_SESSION['status']))
                                {
                                    echo $_SESSION['unm']; 
                                }
                                else
                                {   
                                    echo 'Book Store';
                                }
                            ?>
                </div>
          <div class=" h_menu4">
                <ul class="memenu skyblue">
                      <li class="active grid"><a class="color8" href="index1.php">Home</a></li> 
                      <li><a class="color1" href="#">Categories</a>
                      <div class="mepanel">
                                                <div class="row">
                     
                                        <?php
                                    $query="select * from category ";
                                    $res=mysqli_query($conn,$query);
                                   
                                    while($row=mysqli_fetch_assoc($res))
                                    { 
                                      echo'         <div class="col1">
                                                      <div class="h_nav">
                                                        <ul>';
                                  
                                         echo '<li>
                                                <a href="subcat.php?cat='.$row['cat_id'].'&catnm='.$row["cat_nm"].'">'.$row["cat_nm"].'
                                                </a>
                                               </li>';

                                       
                                                
                                        
                                         }
                                                    echo'   </ul> 
                                                    </div>                            
                                              </div>';





                                            mysqli_close($conn);
                                          ?>

                        
                        
                                        
                    
                   
                                
                <li><a class="color6" href="contact.html">Contact Us</a></li>
              </ul> 
            </div>
                
                <div class="clearfix"> </div>
        </div>
        </div>

    </div>
    

The problem is when I try to open the files from localhost only the header of the page appears so this is the result:enter image description here How is it possible that the form doesnt appear?

</div>
  • 写回答

2条回答 默认 最新

  • drzrdc1766788 2016-08-16 22:21
    关注

    I assume, that your header.php begins a proper html page with doctype, <html> etc... but after

    <?php include "header.php"; ?>
    

    you start your html file again:

    <html>
    <head></head>
    <body>
    

    Make sure your markup is valid!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证