33 thoughts on “PHP : Creating a CMS in 1 HOUR

  1. Sir i am having trouble deleting my articles.Here is my code :

    <?php

    session_start();

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

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

    $info = new Info;

    if (isset($_SESSION['logged_in'])){

    if (isset($_GET['id'])){

    $id = $_GET['id'];

    $query = $pdo->prepare('DELETE FROM info WHERE info_id=?');

    $query->bindValue(1, $id);

    $query->execute();

    header('Location:delete.php');

    }

    $infos = $info->fetch_all();

    ?>

    <html>

    <head>

    <title>CMS Tutorial</title>

    <link rel="stylesheet" href="../assets/style.css">

    </head>

    <body>

    <div class="container">

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

    <br /><br />

    <h4> Select an Announcement to Delete:</h4>

    <form action="delete.php" method="get">

    <select onchange="this.form.submit();" name="id">

    <?php foreach ($infos as $info){ ?>

    <option value="<?php $info['info_id']; ?>">

    <?php echo $info['info_title']; ?>

    </option>

    <?php } ?>

    </select>

    </form>

    </div>

    </body>

    </html>

    <?php

    }else{

    header('Location: index.php');

    }

    ?>

    Here i have replaced 'article' with 'info' . Please sought my problem.

  2. good tutorial but I didn't understand in which part you linked to the article. I mean how from the lorem ipsum you got to the article display. How you made that link.

  3. For those of you who are having trouble deleting the first blog post, here's the fix:

    <option value="" selected disabled>Blogs:</option> //this creates a disabled option, but it must be selected or it will still select the first ENABLED option aka the first blog post.

    <option value="<?php echo $blog['blog_id']; ?>">
    <?php echo $blog['blog_title']; ?>

    </option>

    Might be worth mentioning, I used my own naming conventions, where you see $blog it should say $article, and so forth.

  4. This is a quality lesson my friend. I'm trying to help my buddy build a website for his farm and am looking at building the blog portion of the site. This is perfect for that! So long as I can style everything I need to accordingly. Thanks for taking the time to show us this. Much obliged.

  5. It takes me one day to make everything correct on my PC and I don't know why after I have logged I can't log again if I come back to that page, could you help me? By the way, I really appreciate your work. You helped me a lot!

  6. Thanks for sharing, you make it look so easy…now I get how it is done in php and mysql database connection overview/concept. I've been looking for this, others taught too much and distract me.

  7. Hello thank you for your explanation.
    Can you please tell me how to get the content of the article after selecting the title from the dropdownlist in a text area.
    Thank you.

  8. 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.

  9. 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 } ?>

  10. Code3 Academy have you abandoned your YouTube account? No replies to comments and no new videos. You have great content I wish you were still around.

  11. 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

Your email address will not be published. Required fields are marked *