<?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'];
}
}
$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'];
}
}