php - 在 localhost 中执行代码时,php 文件中的部分 html 文件没有出现

标签 php css html twitter-bootstrap

我正在创建一个注册页面,其中包括 Bootstrap 中的 php、html 和 css。这是我的 php 文件。

<?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>

这是我的 header.php 文件:

<?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>
	

问题是当我尝试从本地主机打开文件时,只出现页面的标题,结果是这样的:enter image description here 表格怎么可能不出现?

最佳答案

我假设,您的 header.php使用 doctype 开始一个正确的 html 页面,<html>等等...但是之后

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

你再次开始你的 html 文件:

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

确保您的标记有效!

关于php - 在 localhost 中执行代码时,php 文件中的部分 html 文件没有出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38985374/

相关文章:

php - 将 xdebug 与前端 js SPA 一起使用?

php - MySQL 查询的混合结果,如何排序

javascript - 开始滚动时将 div 粘贴到页面顶部

javascript - 使用 d3.js 添加下拉菜单

css - 标题还是图例?

android - Android WebView 加载图片有什么好方法?

php - session_start() 在 mac 上不工作

php - 无法在 UBUNTU 中安装 LAMP 服务器

html - 登录后网站不重定向到指定页面

javascript - 如何通过 JavaScript 操作 CSS @keyframes?