PHP : Creating a CMS in 1 HOUR




Download Exercise Files : https://goo.gl/rSHs5e.

Original source


32 responses to “PHP : Creating a CMS in 1 HOUR”

  1. Hello, is there a way of getting in touch with you via email? I have a couple of questions for you. Basically, I would like to ask you about how to build an e-learning platform. I know there are many, and I can use one of them, but to be honest I don´t really like their design and usability. So I am interested in creating something from scratch. And I have some questions regarding the creation of a quiz page with multiple question types. I don´t know where to start. What language I could use the create this. Thanks in advance.

  2. Incorrect details error :/

    <?php

    session_start();

    include_once('../includes/connection.php');

    if (isset($_SESSION['logged_in'])) {
    // display index

    } else {

    if (isset($_POST['username'], $_POST['password'])) {

    $username = $_POST['username'];
    $password = md5($_POST['password']);

    if (empty($username) or empty($password)) {
    $error = 'All fields are required!';
    } else {
    $query = $db->prepare("SELECT * FROM users WHERE user_name = ? user_password = ?");

    $query->bindValue(1, $username);
    $query->bindValue(2, $password);

    $query->execute();

    $num = $query->rowCount();

    if ($num == 1) {
    // user entered correct details
    $_SESSION['logged_in'] = true;

    header('Location: index.php');
    exit();

    } else {
    // user entered false details
    $error = 'Incorrect details!';
    }

    }
    }

    ?>

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport"
    content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>CMS Tutorial</title>
    <link rel="stylesheet" href="../assets/css/style.css">
    </head>
    <body>

    <div class="container">
    <a href="index.php" id="logo">CMS</a>

    <br /><br />

    <?php if (isset($error)) { ?>
    <small style="color:#aa0000;"><?php echo $error; ?></small>
    <br /><br />
    <?php } ?>

    <form action="index.php" method="post" autocomplete="off">
    <input type="text" name="username" placeholder="Username" />
    <input type="password" name="password" placeholder="Password" />
    <button type="submit">Login</button>
    </form>
    </div>

    </body>
    </html>

    <?php } ?>

  3. Thank you, I also added there welcome message for user:
    if ($num == 1) {

    $_SESSION['logged_in'] = true;

    session_start();

    $_SESSION['user_name'] = $username;

    and then:

    <div class = "container">

    <a href="../index.php" id="logo">CMS</a>

    <p>Welcome,

    <?php

    echo $_SESSION['user_name'];

    ?>

    </p>

    <ol>

    <li><a href="add.php">Add Article</a></li>

    <li><a href="delete.php">Delete Article</a></li>

    <li><a href="logout.php">Logout</a></li>

    </ol>

Leave a Reply