There is a gap between databases and what we know about front-end: there is no way for our HTML pages to directly connect to the database. This requires a server-side language, and PHP is one of the most popular choices --- mainly because PHP is more or less an upgraded version of HTML in practicality.
The Exercise Materials archive contains three files: detail.php
, home.php
and upload.php
. They will come in handy.
In order to proceed with the exercise, you must be fluent in the following:
Create your new folder in the ocad.ckprototype.com server, and generate the following files:
index.php
(homepage)detail.php
(single article view)post.php
(article creation form)upload.php
(script for posting to database)footer.php
(footer section shared by index, detail, and post)header.php
(header section shared by index, detail, and post)Open up index.php
, and simply set up your page based on starter template offered by Bootstrap (http://getbootstrap.com/docs/4.6/getting-started/introduction/#starter-template):
Now, go ahead and copy the contents from home.php
found in the Exercise Materials archive:
The result is an unsightly one, as the necessary styling is missing, along with extra components that we do not need:
Refer to the Bootstrap documentation (https://getbootstrap.com/docs/4.4/components/alerts/) and clean up the code. We will use the <form>
element in another file: post.php
.
Now we can be happy with the result, complete with text flowing in from the database:
<?
and ?>
.https://www.dropbox.com/scl/fi/r0itf9ic5hdwnxoz4a9nq/Page-2.mov?rlkey=59g6cm27k85h00fdpt69irn44&dl=0