Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a small web application that functions as a user\'s personal blog using H

ID: 3810456 • Letter: C

Question

Create a small web application that functions as a user's personal blog using HTML, PHP, CSS, and MySQL.

The blog should have at least 2 pages.

1. First page is the "create post" page which allows the user to create a blog entry. In the page it should display a text box where the user enters a title for their blog entry, a text box where the user enters text for a post, a text box where they can specify a tag for the blog entry, and submit and reset buttons. The action attribute should point to the php program.

2. When the user enters the blog entry, the data should be saved in a database table by the PHP program. A database table needs to be created first to hold data from the form html. Also when creating the database table think about how to give unique primary keys to new entries that will be added to the database table from the HTML (Refer to auto increment option in MySQL).

3. The "blog view" page that is displayed to the user after they submit a blog post should also display all blog entries that the user has previously entered. These entries are retrieved from the database. Also include link that takes the user back to the create post page so the user can enter another blog post. This page should be like a regular html page.

Explanation / Answer

1. First of all css is to provide the consistent style to the pages and can be referred from your html/php files.

Create a css file and html file with any editor.

2. Start with a simple php program as below:

   <html>

   <head>

   <title>My test PHP page</title>

   </head>

   <body>

   <?php   

   echo "Today the date is " .date("r");

   ?>

   </body>

   </html>

3. Check in your server how you can create a new database and fields and proceed to create those.

You require 2 tables:

1. For the members

2. For the posts.

In MySQL, you ca create these tables first with some commands as below or directly:

CREATE TABLE `members` (

`memberID` int(11) unsigned NOT NULL AUTO_INCREMENT,

`username` varchar(255) DEFAULT NULL,

`password` varchar(255) DEFAULT NULL,

`email` varchar(255) DEFAULT NULL,

PRIMARY KEY (`memberID`)

)

and

CREATE TABLE `posts` (

`postID` int(11) unsigned NOT NULL AUTO_INCREMENT,

`postTitle` varchar(255) DEFAULT NULL,

`postDesc` text,

`postCont` text,

`postDate` datetime DEFAULT NULL,

PRIMARY KEY (`postID`)

)

Unique primary keys have been given here in the 2 tables.

4. First make html forms without connection to database and whether it meets the required navigation and fields on the screen.

5. Modify the html forms to update the records.

<?php

//in the form submit, add below code to write the blog post in the database

  if(isset($_POST['submit'])){

     $_POST = array_map( 'stripslashes', $_POST );

     //collect form data

     extract($_POST);

     //validation

     if($postID ==''){

         $error[] = 'This post is missing a valid id!.';

     }

     if($postTitle ==''){

         $error[] = 'Please enter the title.';

     }

     if($postDesc ==''){

         $error[] = 'Please enter the description.';

     }

     if($postCont ==''){

         $error[] = 'Please enter the content.';

     }

     if(!isset($error)){

         try {

             //insert into database

             $stmt = $db->prepare('UPDATE posts SET postTitle = :postTitle, postDesc = :postDesc, postCont = :postCont WHERE postID = :postID') ;

             $stmt->execute(array(

                 ':postTitle' => $postTitle,

                 ':postDesc' => $postDesc,

                 ':postCont' => $postCont,

                 ':postID' => $postID

             ));

             //redirect to index page

             header('Location: index.php?action=updated');

             exit;

         } catch(PDOException $e) {

         echo $e->getMessage();

         }

     }

  }

  ?>

6. Add more functionalities as this works.

This is a complete project and hence guidelines are provided with some ideas to help you learn.

Any specific queries that you have once you start making the blog please post with the relevant code.

Best wishes.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote