This article describes how to create a complete blog from PHP and My SQL database. You can create, edit, update and publish PHP and MySQL database. Your audience can browse the catalog of blog articles and click on any article they want to read. Follow this process. You can quickly learn how to create a blog in PHP and a MySQL database.
Features
- Two types of users such as: administrator and normal Users are managed by the user registration system.
- Admin area and public area are separated from each other in the blog.
- Admin user can only login to the administration area and in the general area. in public area, normal user can only log in.
- There are two types of admin in admin area:
- Admin:
- Any post can create, update, posted, or deleted
- The topic can also create, delete, update, or post
- The admin can also delete, update, or view another admin user.
- Author
- The author can create, update and delete only their own posts.
- A particular topic is chosen for each post.
- Each public post lists the author, the characteristics of the image, the date and so on.
Implementation
Let’s start programming. Project name complete-blog-php. In our server directory (htdocs or WWW), create a folder called complete-blog-php. In your text editor of choice, open this folder as Sublime Text. Create a subfolder inside: admin, include and static.
In the root folder of this application, create a file called index.php :
Open this folder and paste the following code into it:
Recent Articles
We included some Google Fonts links between the tags. We also provide the link to our public_styling.css style file. Our entire application is wrapped with
To see this go to: http://localhost/complete-blog- php/index.php.
For site design, static folders will be kept. Inside the static folder create 3 folders: css, images, js. In the CSS subfolder, simply create the file: public_styling.css.
Open public_styling.css and paste the following code:
/**************** * * *** DEFAULTS ****************/ * { margin: 0px; padding: 0px; } html { height: 100%; box size: border box; } body { position: relative; margin: 0; lower padding: 6rem; min-height: 100%; } /* DEFAULT HEADERS */ h1, h2, h3, h4, h5, h6 { color: #444; font-family: ‘Averia Serif Libre’, italic; } a { text-decoration: none; } ul, ol { left margin: 40px; } time { margin: 10px 0px; opacity: .25; } /* DEFAULT FORM */ form h2 { margin: 25px auto; text alignment: center; font-family: ‘Averia Serif Libre’, italic; } input form { width: 100%; screen lock; padding: 13px 13px; font size: 1em; margin: 5px auto 10px; border-radius: 3px; box size: border box; Transparent background; border: 1px solid #3E606F; } input form: focus { outline: none; } /* DEFAULT BUTTON */ .btn { color: white; background: #4E6166; text alignment: center; border: none; border-radius: 5px; screen lock; letter spacing: .1em; margin: 10px 0px; padding: 13px 20px; text-decoration: none; } .container { width: 80%; margin: 0px automatic; } /* NAVBAR */ .navbar { margin: 0 auto; overflow: hidden; background color: #3E606F; border-radius: 0px 0px 6px 6px; } .navbar ul { list style type: none; float right; } .navbar ul li { float: left; font-family: ‘Noto Serif’, serif; } .navbar ul li a { screen: block; White color; text alignment: center; padding: 20px 28px; text-decoration: none; } .navbar ul li a: hover { color: #B9E6F2; background color: #334F5C; } /* LOGO */ .navbar .logo_div { float: left; top padding: 5px; padding-left: 40px; } .navbar .logo_div h1 { color: #B9E6F2; font size: 3em; letter spacing: 5px; font weight: 100; type family: ‘Tangerine’, italic; } /* FOOT FOOT */ .footer { position: absolute; right: 0; bottom: 0; left: 0; White color; background color: #73707D; text alignment: center; width: 80%; margin: 20px auto 0px; padding: 20px 0px; }
This code starts with a default style followed by a navbar style. We create the include folder at the beginning by repeating the header, footer and navigation bar sections. We create some folders at the beginning called include. Now we create three sections in these three folders head section.php, navbar.php and footer.php.
Go to the index.php file and include the tag directly in
After that, go back to the index.php file and replace the code as follows:
The immediately follows this inclusion line in the
Paste the following line – Paste into the footer. php the following line –
Created the config.php file as in index.php. now use ROOT_PATH variable on included files. After all these changes, index.php will look like this:
Recent Articles
These are mainly the basic steps that are set up in the public area. In this process. You can quickly learn how to create a blog in PHP and a MySQL database. I hope you enjoy the tutorial session.
.