MVC (Model - View - Controller) is a software architectural pattern for implementing user interfaces on computers. As someone gets deep in web (or software) development, he/she should understand the principles that come from MVC.
This project uses the above idea. With that in mind, I created a simple blog style personal website, mainly for study purposes and better understanding of modern web development.
Requirements:
- PHP version 5.5 and above.
Third party modules:
- PHPMailer ( used in contact form )
To test the project in your machine you have to change the following options in files:
- email.php ( under models )
Set
$mail->Username = "[email protected]";
$mail->Password = "your_application_password";
$mail->addAddress("[email protected]");
To get a Gmail application password follow the official guide.
- dependences.php ( under config )
In this file the only you want to change is the $_Title
variable that holds the title of each page.
The project uses many-accounts relationship. This means that there is only one admin account which can edit-delete all the other members posts as well to write his/her own. All the other accounts are personal and can manipulate only their posts.
To register an account (as there is no such thing as register form) you have to contact to admin by contact page and request one member account.
The administrator of the website needs to change a line so the server can recognize him.
- admin.variables.com ( under members/config )
Change $adminEmail
variable with your own domain.
For better security use a custom domain.
Example: [email protected]
The domain of each user is shown in the footer area of each post in this format:
Added on Day Month Year from member's email
For administator posts the member's email
section is filled with the following account :
some_name @epost.com
You have to change the following files to be able to connect to Mysql database.
- db.php ( under config )
Set the following options with your credentials:
define('DBHOST','host');
define('DBUSER','user');
define('DBPASS','password');
define('DBNAME','name');
The database uses two tables. One is called blog_members
and the other blog_post
.
The members table holds the admin account as well as all the other users. To set a new account you have to type manually an SQL Insert comand like so:
INSERT INTO `blog_members`(`username`, `password`, `email`) VALUES ('someUserName','somePassword','comeEmail')
If you are new to Mysql, please install phpMyAdmin for better command support.
For Member Database Schema see: members/members_schema.sql
The post table holds the title, a description and the main content of each post as well as the date of creation.
For Posts Database Schema see: blog/posts_schema.sql
We add a helper php script called bcrypt.php under root directory. This script takes as input a text value and returned the hashed one. The feature adds some security to our members as we verify now their passwords using bcrypt.
As we use password_verify()
to verify their passwords from database, you must store the hashed password and not use plain text one.