posts.php
Go to the documentation of this file.
<?php
include('server.php');
if(isset($_SESSION['loggedin']))
{
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>PlacementExperience | Posts</title>
<!-- Bootstrap -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@800&family=Roboto+Mono&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap" rel="stylesheet">
<!--user icon -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- External CSS -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="row">
<div class="col-sm-3" style="left:0px;">
<div class="container-fluid sidenav">
<a href="mainpage.php"><img src="img/logoo.png" style="width:100px; margin-top:15px;"></a>
<br><br>
<div id="cse">
<a style="text-decoration: none;" href="https://www.cse.iitb.ac.in" target="_blank">
<h6 style="text-align: center;">Department of</h6>
<h6 style="text-align: center;">Computer Science and Engineering</h6>
<h5 style="text-align: center;">IIT Bombay</h5>
</a>
</div>
<br><br>
<ul>
<li><a href="mainpage.php"> HOME </a></li>
<li><a href="posts.php"> POSTS </a></li>
<li><a href="exp_form.php">SHARE</a></li>
<li><a href="profile.php"> PROFILE </a></li>
</ul>
<br><br>
<div id="iLinks">
<h5>Important Links</h5>
<ul>
<li style="font-size:10px;"><a href="http://www.iitb.ac.in/" target=_blank> IITB Home</a></li>
<li style="font-size:10px;"><a href="https://www.cse.iitb.ac.in/"> CSE@IITB </a></li>
<li style="font-size:10px;"><a href="https://asc.iitb.ac.in/"> ASC </a></li>
</ul>
</div>
<br><br>
</div>
</div>
<div class="container-fluid col-md-8 whole" style="margin-top:0px;">
<div class="row">
<div class="col-sm-8 main" id="title">
<img src="img/heading_trans.png" alt="placementExperience" style="align-content: center; margin-left: 25%; margin-right: 25%;">
</div>
<div class="col-sm-4" style="left:0px; padding-top:20px; vertical-align: center;">
<button id="logout" type="button" class="btn btn-info btn-round" style="float:right;">
Logout
</button>
<a href="profile.php"><i class="fa fa-user-circle-o" style="font-size:36px; float:right; padding-right:10px;" ></i></a>
</div>
</div>
<hr class="lineform">
<h3 style="color: #e67f11; text-align: center">Posts</h3>
<!-- Search Field -->
<div style="float:right">
<form action="" method="post">
<input id="search" name="search" type="text" placeholder="Search By Company Name" onkeyup="stoppedTyping()">
<input class="primary" id="submit" name="searchbtn" type="submit" value="Search">
</form>
</div>
<br><br>
<!--Fetching Posts -->
<?php
$user_email = $_SESSION['Logged_email'];
if(!isset($_POST['searchbtn'])){
$sql = "SELECT id,name, companyname, story, roundprovided, created_at FROM posts ORDER BY created_at DESC";
$result = mysqli_query($db, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
?>
<div class="card bg-white" style="border:3px solid gray;">
<div class="card-header">
<?php echo '<p id="post_headings"><b>Name:</b> ' .$row['name']. '</p>';?>
<?php echo '<h4 id="post_company"><b>Company:</b> '.$row['companyname'].'</h4>';?>
<?php echo '<p id="post_company"><b>Round Provided:</b> '.$row['roundprovided'].'</p>';?>
</div>
<div class="card-body">
<?php echo '<p id="post_body"> '.$row['story'].'</p>'; ?>
</div>
<div class="card-footer">
<?php echo '<h6 style="float: right;"> Posted on '.date('jS M Y', strtotime($row['created_at'])).'</h6>';?>
</div>
</div>
<br><br>
<?php
}
}
}else{
$search = $_POST['search'];
$sql = "SELECT id,name, companyname, story, roundprovided, created_at FROM posts WHERE companyname like '$search%' ORDER BY created_at DESC";
$result = mysqli_query($db, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
?>
<div class="card bg-white" style="border:3px solid gray;">
<div class="card-header">
<?php echo '<p id="post_headings"><b>Name:</b> ' .$row['name']. '</p>';?>
<?php echo '<h4 id="post_company"><b>Company:</b> '.$row['companyname'].'</h4>';?>
<?php echo '<p id="post_company"><b>Round Provided:</b> '.$row['roundprovided'].'</p>';?>
</div>
<div class="card-body">
<?php echo '<p id="post_body"> '.$row['story'].'</p>'; ?>
</div>
<div class="card-footer">
<?php echo '<h6 style="float: right;"> Posted on '.date('jS M Y', strtotime($row['created_at'])).'</h6>';?>
</div>
</div>
<br><br>
<?php
}
}else{echo '<em style="color:red; font-size:50px;"><i>No Result Found</i></em>';}
}
mysqli_close($conn);
?>
</div>
</div>
</div>
<br><br>
<div class="footer">
<p style="color:#e88924">&#9400; Copyright@IITB</p>
</div>
<!-- Bootstrap scripts -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script type="text/javascript">
document.getElementById("logout").onclick = function () {
location.href = "logout.php";
};
</script>
</body>
</html>
<?php
}
else{
header("location: index.php");
}
?>