Skip to content

Commit 7163e8a

Browse files
committed
first commit
0 parents  commit 7163e8a

20 files changed

+658
-0
lines changed

blogs.sql

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
-- phpMyAdmin SQL Dump
2+
-- version 4.1.14
3+
-- http://www.phpmyadmin.net
4+
--
5+
-- Host: 127.0.0.1
6+
-- Generation Time: Nov 21, 2016 at 05:51 PM
7+
-- Server version: 5.6.17
8+
-- PHP Version: 5.5.12
9+
10+
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11+
SET time_zone = "+00:00";
12+
13+
14+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
15+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
16+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
17+
/*!40101 SET NAMES utf8 */;
18+
19+
--
20+
-- Database: `blogs`
21+
--
22+
23+
-- --------------------------------------------------------
24+
25+
--
26+
-- Table structure for table `cat`
27+
--
28+
29+
CREATE TABLE IF NOT EXISTS `cat` (
30+
`id` int(200) NOT NULL AUTO_INCREMENT,
31+
`cate` varchar(200) NOT NULL,
32+
PRIMARY KEY (`id`)
33+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
34+
35+
--
36+
-- Dumping data for table `cat`
37+
--
38+
39+
INSERT INTO `cat` (`id`, `cate`) VALUES
40+
(1, 'html'),
41+
(2, 'css'),
42+
(3, 'php');
43+
44+
-- --------------------------------------------------------
45+
46+
--
47+
-- Table structure for table `comment`
48+
--
49+
50+
CREATE TABLE IF NOT EXISTS `comment` (
51+
`id` int(200) NOT NULL AUTO_INCREMENT,
52+
`post_id` varchar(200) NOT NULL,
53+
`author` varchar(200) NOT NULL,
54+
`comm` varchar(200) NOT NULL,
55+
PRIMARY KEY (`id`)
56+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=66 ;
57+
58+
--
59+
-- Dumping data for table `comment`
60+
--
61+
62+
INSERT INTO `comment` (`id`, `post_id`, `author`, `comm`) VALUES
63+
(50, '9', 'zihad', 'gggg'),
64+
(51, '9', 'zihad', 'aaa'),
65+
(52, '9', 'zihad', 'sss'),
66+
(53, '9', 'zihad', 'sss'),
67+
(54, '10', 'nahid', 'goood'),
68+
(55, '10', 'nahid', 'bad'),
69+
(56, '10', 'nahid', 'gf'),
70+
(57, '10', 'nahid', 'sfsdf'),
71+
(58, '10', 'nahid', 'aaaa'),
72+
(59, '10', 'nahid', 'qqqqq'),
73+
(60, '10', 'nahid', 'qqqqqqqqqqqq'),
74+
(61, '10', 'nahid', 'qqqqqqqqqq'),
75+
(62, '10', 'nahid', 'qqqqqqqqqqq'),
76+
(63, '9', 'nahid', 'aaaaa'),
77+
(64, '10', 'nahid', 'aaaaaaaaaaaaa'),
78+
(65, '11', 'rafi', 'nice');
79+
80+
-- --------------------------------------------------------
81+
82+
--
83+
-- Table structure for table `post`
84+
--
85+
86+
CREATE TABLE IF NOT EXISTS `post` (
87+
`id` int(200) NOT NULL AUTO_INCREMENT,
88+
`user_id` int(200) NOT NULL,
89+
`title` text NOT NULL,
90+
`dis` text NOT NULL,
91+
`author` text NOT NULL,
92+
`cat` text NOT NULL,
93+
PRIMARY KEY (`id`)
94+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
95+
96+
--
97+
-- Dumping data for table `post`
98+
--
99+
100+
INSERT INTO `post` (`id`, `user_id`, `title`, `dis`, `author`, `cat`) VALUES
101+
(9, 3, 'প্রিয় খেলোয়াড় রানআউট হলে...', 'প্রিয় খেলোয়াড় রানআউট হলে মনটাই খারাপ হয়ে যায়। যেন মন খারাপ না হয় তাই এই খেলোয়াড়টিকে নট আউট করে সেই ছবিটির স্ক্রিনশট কমেন্টে শেয়ার কর।', 'zihad', 'html'),
102+
(10, 3, 'পুণেতে চিন-ভারত যৌথ মহড়া চলছে', 'তার মাঝেই চিনে ভারতের সেনাপ্রধান, চিনের শীর্ষ সেনা কর্তাও ভারতে আসছেন, অশনি সঙ্কেত পশ্চিম সীমান্তের ও পারে', 'zihad', 'html'),
103+
(11, 6, 'Winter is here!!! Now', 'Winter is here!!! Now, It''s time to upgrade your wardrobe with trendy outfits. New stylish Full Sleeve Shirts are now available on Kiksha. Only Taka 599. Just order online', 'rafi', 'php');
104+
105+
-- --------------------------------------------------------
106+
107+
--
108+
-- Table structure for table `reg`
109+
--
110+
111+
CREATE TABLE IF NOT EXISTS `reg` (
112+
`id` int(111) NOT NULL AUTO_INCREMENT,
113+
`name` varchar(200) NOT NULL,
114+
`email` varchar(200) NOT NULL,
115+
`password` varchar(200) NOT NULL,
116+
PRIMARY KEY (`id`)
117+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
118+
119+
--
120+
-- Dumping data for table `reg`
121+
--
122+
123+
INSERT INTO `reg` (`id`, `name`, `email`, `password`) VALUES
124+
(3, 'zihad', '[email protected]', '827ccb0eea8a706c4c34a16891f84e7b'),
125+
(5, 'nahid', '[email protected]', '827ccb0eea8a706c4c34a16891f84e7b'),
126+
(6, 'rafi', '[email protected]', '827ccb0eea8a706c4c34a16891f84e7b');
127+
128+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
129+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
130+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

config.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
$dbhost = 'localhost';
4+
$dbname = 'blogs';
5+
$dbuser = 'root';
6+
$dbpass = '123456';
7+
8+
try{
9+
$db = new PDO("mysql:host={$dbhost};dbname={$dbname}",$dbuser,$dbpass);
10+
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
11+
}
12+
catch(PDOException $e){
13+
echo "connection error".$e->getmessage();
14+
}
15+
?>

image/15.jpg

163 KB
Loading

image/16.jpg

163 KB
Loading

image/17.png

45.7 KB
Loading

image/18.jpg

45.4 KB
Loading

includes/footer.inc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
</td>
2+
</tr>
3+
</table>
4+
5+
6+
</body>
7+
</html>

includes/header.inc

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
include("config.php");
3+
?>
4+
5+
<!DOCTYPE html>
6+
<html lang="en">
7+
<head>
8+
<meta charset="UTF-8">
9+
<title>iBlog</title>
10+
</head>
11+
<body>
12+
13+
14+
15+
<table width="1000px" align="center">
16+
<?php
17+
require_once 'includes/menu.inc';
18+
?>
19+
<tr>
20+
<td>

includes/menu.inc

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<tr>
2+
<td><h1>iBlog</h1></td>
3+
</tr>
4+
5+
<tr>
6+
<td><a href="home">Home</a></td>
7+
</tr>
8+
9+
<tr>
10+
<td><a href="profile">Profile</a></td>
11+
</tr>
12+
13+
<tr>
14+
<td><a href="signup">singup</a></td>
15+
</tr>
16+
17+
<tr>
18+
<td><a href="login">login</a></td>
19+
</tr>
20+
21+
<tr>
22+
<td><a href="logout">logout</a></td>
23+
</tr>

index.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
include 'includes/header.inc';
3+
4+
$requestUri = $_SERVER['REQUEST_URI'];
5+
$uriSegment = explode('?', $requestUri);
6+
$uri = $uriSegment[0];
7+
8+
$uri = $uri == '/'?'home':$uri;
9+
$uri = $uri == '/'?'login':$uri;
10+
$uri = $uri == '/'?'post':$uri;
11+
$uri = $uri == '/'?'login':$uri;
12+
$uri = $uri == '/'?'profile':$uri;
13+
$uri = $uri == '/'?'comment':$uri;
14+
$uri = $uri == '/'?'logout':$uri;
15+
$uri = $uri == '/'?'edit':$uri;
16+
$uri = $uri == '/'?'delete':$uri;
17+
18+
$page = $uri . '.page.php';
19+
20+
if(file_exists('pages/' . $page)) {
21+
require 'pages/' . $page;
22+
}
23+
24+
25+
26+
include 'includes/footer.inc';

pages/comment.page.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
session_start();
3+
include('config.php');
4+
?>
5+
6+
<?php
7+
$id = $_POST['post_id'];
8+
9+
if(isset($_POST['post'])){
10+
$comment = $_POST['comment'];
11+
12+
try{
13+
$statement = $db->prepare("insert into comment (post_id,author,comm) values (?,?,?)");
14+
$statement->execute(array($id,$_SESSION['uname'],$comment));
15+
}
16+
catch(Exception $e){
17+
$error_message = $e->getmessage();
18+
}
19+
}
20+
?>
21+
<?php
22+
header('location: post?id=' . $id);
23+
?>

pages/delete.page.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
include("config.php");
3+
?>
4+
5+
<?php
6+
$id = $_GET['post_del'];
7+
8+
$query = $db->prepare("DELETE FROM post WHERE id=?");
9+
$query->execute(array($id));
10+
header('location: profile');
11+
12+
13+
?>

pages/edit.page.php

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
require_once 'includes/header.inc';
3+
?>
4+
5+
<?php
6+
7+
if(isset($_POST['post_edit'])){
8+
$title = $_POST['title'];
9+
$dis = $_POST['description'];
10+
$cat = $_POST['cat'];
11+
$id = $_GET['edit_post'];
12+
13+
try{
14+
$statement = $db->prepare("UPDATE post SET title=?, dis=?, cat=? WHERE id=?");
15+
$statement->execute(array($title,$dis,$cat,$id));
16+
17+
header('location: profile');
18+
}
19+
catch(Exception $e){
20+
$error_message =$e->getmessage();
21+
}
22+
}
23+
?>
24+
25+
26+
<?php
27+
$id = $_GET['edit_post'];
28+
$query = $db->prepare ("SELECT * FROM post where id=?");
29+
$query->execute(array($id));
30+
$result = $query->fetchAll (PDO::FETCH_ASSOC);
31+
32+
foreach ($result as $row){
33+
$old_title = $row['title'];
34+
$old_dis = $row['dis'];
35+
$old_cat = $row['cat'];
36+
37+
}
38+
?>
39+
40+
<form action="" method="post" enctype="multipart/form-data">
41+
<table>
42+
<tr>
43+
<td><label>Title :</label></td>
44+
<td><input value="<?php echo "$old_title";?>" required="" class="" placeholder="Title" name="title" id=""></td>
45+
</tr>
46+
<tr>
47+
48+
<td><label>post :</label></td>
49+
<td><textarea required="" class="form-control" placeholder="Description..." name="description" id="" rows="3"><?php echo "$old_dis";?></textarea>
50+
</td>
51+
52+
</tr>
53+
<td><label>Select Tags</label></td>
54+
<td><select required class="cat" name="cat">
55+
<option value=""><?php echo "$old_cat";?></option>
56+
<?php
57+
$query = $db->prepare("SELECT * FROM cat");
58+
$query->execute();
59+
$result = $query->fetchAll(PDO::FETCH_ASSOC);
60+
61+
foreach ($result as $row){
62+
$cat_name = $row['cate'];
63+
64+
?>
65+
<option value="<?php echo "$cat_name";?>"><?php echo "$cat_name";?></option>
66+
67+
<?php } ?>
68+
</select></td>
69+
70+
<tr>
71+
<td><input type="submit" name="post_edit" class="btn btn-primary pull-left"></td>
72+
73+
<?
74+
require_once 'includes/footer.inc';
75+
?>

pages/home.page.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
$i = 0;
3+
$query = $db->prepare("SELECT * FROM post order by id desc");
4+
$query->execute();
5+
$result = $query->fetchAll(PDO::FETCH_ASSOC);
6+
7+
foreach($result as $row){
8+
$i++;
9+
$id = $row['id'];
10+
$title = $row['title'];
11+
$dis = $row['dis'];
12+
$author = $row['author'];
13+
$cat = $row['cat'];
14+
$count = $row['count'];
15+
$image = $row['image'];
16+
17+
?>
18+
19+
<img src='image/<?php echo $image;?>' alt="" height="300" width="500"/>
20+
<h2><a href="post?id=<?= $row['id'];?>"><?php echo $title;?></a></h2>
21+
<p>Category: <?php echo $cat;?> | Post by: <?php echo $author;?> | View: <?php echo $count;?></p>
22+
<p><?php $pieces = explode(" ",$row['dis']);
23+
$post = implode(" ", array_splice($pieces, 0,15));
24+
$post = $post."...";
25+
echo $post;?> <a href="post?id=<?= $row['id'];?>">Read More</a></p>
26+
27+
28+
29+
<?php if ($i==6){
30+
break;
31+
}
32+
33+
} ?>

0 commit comments

Comments
 (0)