简体   繁体   中英

HTML and PHP: How do I arrange my pages correctly?

I really have a problem with my pages... I have currently my style.css for my CSS, index.php for the home page, my "includes" folder for all my includes (navigation.php and header.php) and my register.php: http://prntscr.com/8320hv

I just started coding my work, so there is not much. I have a problem with the organization of my pages. I would like to put some content to my index.php:

http://prntscr.com/832496

Code:

<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Test 2</title>
    <meta charset="UTF-8">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <link href="css/style.css" rel="stylesheet">
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<?php require "includes/navigation.php"; ?>

<?php require "includes/header.php"; ?>

<div class="wrapper">
    <div id="container">
        <div id="breadcrumb-top" class="breadcrumb">
            <ul>
                <li>
                    <a href="#">Home</a>
                </li>
            </ul>
        </div>
        <span class="big-title">Home</span>
        <div id="breadcrumb-bottom" class="breadcrumb">
            <ul>
                <li>
                    <a href="#">Home</a>
                </li>
            </ul>
        </div>
    </div>
</div>
</body>
</html>

But if I would like to go in my register.php file, my index.php is not linked to it: http://prntscr.com/8322hn

I am obliged to operate this way, because I would like to assign a different content for my index.php and my register.php in the container: http://prntscr.com/8323ht

I am really lost with this, so if I could have help, I you acknowledging.

You are doing fine so far, you just need to include the separate content for each page within each page. Having a common navigation .php is a standard thing to do, though I would have navigation.php within the root folder, that way your relative links are easier to manage.

All 4 files in the same folder, with stylesheet.css in a css/ folder:

head.php:

<head>
  <link href="css/stylesheet.css" rel="stylesheet" type="text/css">
</head>

nav.php:

<div class="nav">
  <a href="index.php> home</a> |
  <a href="register.php> register</a>
</div>

index.php:

<html>
  <?php include "head.php"; ?>
  <body>
    <?php include "nav.php"; ?>
    <div class="container">
      <h1>This is home</h1>
    </div>
  </body>
</html>

register.php:

<html>
  <?php include "head.php"; ?>
  <body>
    <?php include "nav.php"; ?>
    <div class="container">
      <h1>This is register</h1>
    </div>
  </body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM