Simple-Ass Content Management System


I recently built a personal project,

A simple content management system and thought I would share it with you guys!

This example is run on local host, built in php and myphpAdmin.

1. Html

<!DOCTYPE html>
		<link rel=stylesheet type ="text/css" href="style.css">
<h1> CMS</h1>
<form action="insert.php" method="post" enctype="multipart/form-data">
<div id="headerBox">
<input type="text" name="subject" id="subject"></div>
<div id="commentBox">
<input type="text" name="textBox" id="textBox"></div>
<input type="file" name="image" />
<div id=button>
<input type="submit" name="submit" id="sendButton" value="send"></div>


The first step is pretty basic, this is mainly setting up the html “skeleton”. When a form is submitted the page is refreshed, the enctype is a multipart from that allows images to be uploaded. There is then some simple div header tags; inside of these are input types, text and file (for the image upload). Finally a submit button.


body {
width: 100%;
height: 100%;
margin: auto;
text-align: center;
text-align: center;
height: 200px;
width: 400px;
margin: auto;


text-align: center;

text-align: center;

text-align: center;


The CSS is fairly simple  and self explanatory the idea is that the form is centered.


3. php admin setup

Create a database layout similar to this.

2017-03-13 (1)

The ID acts as a primary key, Then there is Title and Article which are both varchar data-types. Finally the image is a blob type.




echo "failed to connect: " .mysqli_connect_error();

$subject = mysqli_real_escape_string($con,$_POST['subject']);
$text = mysqli_real_escape_string($con,$_POST['textBox']);

$image = $_FILES['image']['tmp_name'];

$img = file_get_contents($image);

// create a variable

//Execute the query

mysqli_query($con,"INSERT INTO default (Title,Article,Image)
VALUES ('$subj','$artc','$image')");

if(mysqli_affected_rows($con) &gt; 0){
echo "good";
} else {
echo "problem
echo mysqli_error ($con);

So firstly a database connection is made with the credentials of “root” and “password”. After this there is an error handler if the connection isn’t made. Next the image is collected from the file upload.  Article and subject  types are posted.  Lastly the query is fired updating the system, there is an error handler to give feedback if something went wrong.

And That’s it!

Hopefully this helps someone somewhere! Happy coding 🙂




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s