Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config.php
10 changes: 10 additions & 0 deletions example.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
$config['domain'] = "http://localhost"; // Change it to your website URL
$config['name'] = "simpleBlog"; // Change it to your website name

$config['db']['host'] = "127.0.0.1"; // Server of your database
$config['db']['username'] = "root"; // Username of your database
$config['db']['password'] = "toor"; // Password of your database
$config['db']['database'] = "my_blog"; // The name of the database default: my_blog

?>
5 changes: 4 additions & 1 deletion resources/conx.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
$db = mysqli_connect("localhost","root","pass","my_blog");
require '/config.php';
if(!isset($config))
die("Rename your example.config.php to config.php");
$db = mysqli_connect($config['db']['host'],$config['db']['username'],$config['db']['password'],$config['db']['database']);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
Expand Down
50 changes: 11 additions & 39 deletions sql/my_blog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ SET time_zone = "+00:00";

--
-- Database: `my_blog`
DROP DATABASE IF EXISTS my_blog;
CREATE DATABASE my_blog;
USE my_blog;
--

-- --------------------------------------------------------
Expand All @@ -27,12 +30,13 @@ SET time_zone = "+00:00";
--

CREATE TABLE IF NOT EXISTS `posts` (
`post_id` int(11) NOT NULL,
`post_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`contents` text NOT NULL,
`posted_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`filename` varchar(255) NOT NULL
`filename` varchar(255) NOT NULL,
PRIMARY KEY (`post_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- --------------------------------------------------------
Expand All @@ -42,46 +46,14 @@ CREATE TABLE IF NOT EXISTS `posts` (
--

CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(30) NOT NULL,
`password` varchar(35) NOT NULL,
`fname` varchar(20) NOT NULL,
`lname` varchar(20) NOT NULL,
`email` varchar(255) NOT NULL,
`gender` varchar(6) NOT NULL,
`avatar` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `posts`
--
ALTER TABLE `posts`
ADD PRIMARY KEY (`post_id`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`user_id`), ADD UNIQUE KEY `username` (`username`,`email`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `posts`
--
ALTER TABLE `posts`
MODIFY `post_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
`avatar` varchar(255) DEFAULT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY (`username`,`email`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;