search partner displaying posts

//function for displaying posts
function get_posts(){

global $con;
 $per_page=5;
if (isset($_GET['page'])){

$page = $_GET['page'];
}
else{$page=1;}

$start_from = ($page-1) * $per_page;

$get_posts = "select * from posts ORDER by 1 DEC LIMIT $start_from, $per_page";

$run_posts = mysqli_query($con,get_posts);

while ($row_posts=mysqli_fetch_array($run_posts)){

$post_id = $row_posts['post_id'];
$post_title = $row_posts['post_title'];
$post_date = $row_posts['post_date'];
$user_id = $row_posts['user_id'];
$content = $row_posts['post_content'];

//getting the user who has posted the thread
$user = "select * from users where user_id='$user_id' AND posts='yes'";

$run_user = mysqli_query($con,$user);
$row_user = mysqli_fetch_array($run_user);
$user_name = $row_user['user_name'];
$user_image = $row_user['user_image'];

//now displaying all at once

echo"<div id='posts'>
<p><img src='user/user_images/$user_image' width='50' height='50'</p>
<h3><a href='user_profile.php?u_id=$user_id'>$user_name</a></h3>
<h3>$post_title</h3>
<p>$post_date</p>
<p>$content</p>
<a href='single.php?post_id=$post_id' style='float:right;'><button>See Replies or Reply to This </button></div><br/>

";


}

include ("pagination.php");
}


?>

search partner insert posts

<?php
$con = mysqli_connect("localhost","root"," ","social_media") or die ("Connection was not established");
?>

//function for inserting posts
function insertPost(){


if (isset($_POST['sub'])){

global $con;
global $user_id;
$title = addslashes($_POST['title']);
$content = addslashes($_POST['content']);
$topic= addslashes$_POST['topic'];

if ($content==' ' OR $title==' ' ){

echo "<h2>Please enter topic description </h2>";
exit();
}
else {
$insert = "insert into posts(user_id,topic_id,post_title,post_content,post_date) value ('$user_id','$topic', '$title', '$content', NOW())";

$run = mysqli_query($con,$insert);

if($run){
$update = "update users set posts = 'yes' where user_id='$user_id'"
$run_update = mysqli_query($con,$update);
}



}

}




}
//function for displaying posts
function get_posts(){

global $con;

$per_page=5;
if (isset($_GET['page'])){
$page = $_GET['page'];

}

}



search partner insert posts

<?php
$con = mysqli_connect("localhost","root"," ","social_media") or die ("Connection was not established");
?>

//function for inserting posts
function insertPost(){


if (isset($_POST['sub'])){

global $con;
global $user_id;
$title = addslashes($_POST['title']);
$content = addslashes($_POST['content']);
$topic= $_POST['topic'];

if ($content==''){

echo "<h2>Please enter topic description </h2>";
exit();
}
else {
$insert = "insert into posts(user_id,topic_id,post_title,post_content,post_date) value ('$user_id','$topic', '$title', '$content', NOW())";

$run = mysqli_query($con,$insert);

if($run){
$update = "update users set posts = 'yes' where user_id='$user_id'"
$run_update = mysqli_query($con,$update);
}



}

}




}
//function for displaying posts
function get_posts(){

global $con;

$per_page=5;
if (isset($_GET['page'])){
$page = $_GET['page'];

}

}



search partner insert posts

<?php
$con = mysqli_connect("localhost","root"," ","social_media") or die ("Connection was not established");
?>

//function for inserting posts
function insertPost(){


if (isset($_POST['sub'])){

global $con;
global $user_id;
$title = addslashes($_POST['title']);
$content = addslashes($_POST['content']);
$topic= $_POST['topic'];

if ($content==''){

echo "<h2>Please enter topic description </h2>";
exit();
}
else {
$insert = "insert into posts(user_id,topic_id,post_title,post_content,post_date) value ('$user_id','$topic', '$title', '$content', NOW())";

$run = mysqli_query($con,$insert);

if($run){
$update = "update users set posts = 'yes' where user_id='$user_id'"
$run_update = mysqli_query($con,$update);
}



}

}




}
//function for displaying posts
function get_posts(){

global $con;

$per_page=5;
if (isset($_GET['page'])){
$page = $_GET['page'];

}

}



search partner topics display functions

<?php
$con = mysqli_connect("localhost","root"," ","social_media") or die ("Connection was not established");
?>

//function for getting topics

function getTopics(){

global $con;

$get_topics= "select * from topics";

$run_topics = mysqli_query($con,$get_topics);

while($row=mysqli_fetch_array($run_topics)){

$topic_id = $row['topic_id'];
$topic_name = $row['topic_name'];
echo "<option value='$topic_id'>$topic_name</option>";
}



}

search partner logout

logout.php

<?php

session_start();

session_destroy();

header("location:index.php");


?>

search partner content timeline area

<!-----Content timeline starts----->
<div id="content_timeline">
<form action="home.php?id=<?php echo $user_id;?>" method="post" id="f">

<h2>What's your question today? let's discuss!</h2>
<input type="text" name="title" placeholder="Write a Title..." size="82" required="required"/>
<textarea cols="83" rows="4" name="content" placeholder="write description..."></textarea><br/>
<select name="topic"><option>Select Topic</option><?php getTopics();?></select>
<input type="submit" name="sub" value="Post to Timeline"/></form>
<?php insertPost();?>
<h3>Most Recent Discussions!</h3>
<?php get_posts();?></div>





</div>

<!-----Content timeline Ends----->
#content_timeline{
float:right;
width:850px;
padding:10px;
}
.ff input{margin-bottom:5px;}
.ff select{margin-bottom:5px;}
#f input{
padding:7px;
border:1px solid black;
border-radius;5px;
font-weight:bolder;
}
#f textarea{
padding:8px;
border:1px solid black;
border-radius:5px;
font-weight:bolder;
}
#f select{
padding:8px;
border:1px; solid black;
border-radius:5px;
font-weight:bolder;
}
#f select:hover{ background:#FFF8DC}
#f input:hover{ background:#FFF8DC}
#f textarea:hover{ background:#FFF8DC}
#f h2{ color:gray; font-family:Sensational;}