O Sparks
O Sparks

Reputation: 23

How do I edit the css and html of my home.php file

I've just finished creating my login page and would like to edit the homepage users see when they log in. However, the page users are redirected to is home.php. I'm not confident enough with PHP to design the page in it so is there a way I can use html and css instead? Also, I want to add in the navbar I created.

My home.php code

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

Upvotes: 1

Views: 104

Answers (1)

James.Valon
James.Valon

Reputation: 81

First, include the homepage.php in your 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');
}
?>

Then, create the homepage.php file in the same directory. It can have PHP code, HTML, CSS. Also, you can use PHP to generate HTML.

Example home.php

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

Upvotes: 2

Related Questions