如何编辑home.php文件的CSS和HTML

时间:2019-02-27 14:16:02

标签: php html css

我刚刚完成了我的登录页面的创建,并希望编辑用户登录时看到的主页。但是,用户重定向到的页面是home.php。我对PHP不够自信,无法在其中设计页面,所以有没有办法我可以使用html和CSS?另外,我想添加我创建的导航栏。

我的home.php代码

<?php
// check to see if the user is logged in
if ($_SESSION['loggedin']) {
    // user is logged in
    echo 'Welcome ' . $_SESSION['name'] . '!';
} else {
    // user is not logged in, send the user to the login page
    header('Location: index.html');
}
?>

My interface design made using word. (This is how I'm trying to design my home screen. It's for a school project

1 个答案:

答案 0 :(得分:2)

首先,在您的homepage.php中加入home.php

<?php
// check to see if the user is logged in
if ($_SESSION['loggedin']) {
    // user is logged in
    include_once 'homepage.php';
} else {
    // user is not logged in, send the user to the login page
    header('Location: index.html');
}
?>

然后,在同一目录中创建homepage.php文件。它可以具有PHP代码,HTML,CSS。另外,您可以使用PHP to generate HTML

示例home.php

<html>
<head>
    <link href="styles.css">
</head>
<body>
    <h1>Homepage</h1>
    <p>Hello <?= $_SESSION['username' ?>,</p>
</body>
</html>