Micro-Project: Government Polytechnic Solapur
Micro-Project: Government Polytechnic Solapur
Micro-Project: Government Polytechnic Solapur
MICRO-PROJECT
Php(22619)
Forum website
age |1
CERTIFICATE
This is to certify that Mr. Yogesh Dharmasa Gangji . Of Sixth Semester
of Diploma in Computer Technology of Institute Government Polytechnic,
Solapur has completed the micro project work satisfactorily of php for the
academic year 2021-2022 as prescribed in the I-Scheme curriculum.
Abstract
Acknowledgement
We wish to express our profound and sincere gratitude to our guide,
Priyanka Channapattan Ma’am who guided us in the structure of project as
well as some main points in that project also they cleared our all doubts about
micro project. We are Indebted to his constant encouragement, co-operation and
help. It was his enthusiastic support that helped us in overcoming various
obstacles in the project.
3 Chrome 1
7.0 Action Plan (Sequence and time required for major activities for 8 Weeks)
2 Topic searched: -
1. game
2. Class management
3. Forum website
Content Page
2 Aim
3 Resources Used
4 Code o/p
5 Actual Methodology
6 Advantages
7 Conclusion
8 Reference
Introduction
age |7
Aim
HARDWARE
RAM 8GB
SOFTWARE
XAMPP 7.4.29
_dbconn.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "idiscuss";
$conn = mysqli_connect($servername, $username, $password, $database);
?>
age |9
_footer.php
<?php
$showError = "false";
if($_SERVER["REQUEST_METHOD"] == "POST"){
include '_dbconnect.php';
$email = $_POST['loginEmail'];
$pass = $_POST['loginPass'];
$name=$row['name'];
$_SESSION['loggedin'] = true;
$_SESSION['sno'] = $row['sno'];
$_SESSION['useremail'] = $email;
$_SESSION['name'] = $name;
echo "logged in". $email;
}
header("Location:/forum/index.php?user=found");
}
else{
header("Location: /forum/index.php?user=notfound");
}
}
?>
a g e | 10
Handlesignup.php
<?php
$showError = "false";
if($_SERVER["REQUEST_METHOD"] == "POST"){
include '_dbconnect.php';
$user_email = $_POST['signupEmail'];
$user_name = $_POST['signupName'];
$pass = $_POST['signupPassword'];
$cpass = $_POST['signupcPassword'];
$existSql = "select * from `users` where user_email = '$user_email'";
$result = mysqli_query($conn, $existSql);
$numRows = mysqli_num_rows($result);
if($numRows>0){
$showError = "Emailalreadyinuse";
}
else{
if($pass == $cpass){
$hash = password_hash($pass, PASSWORD_DEFAULT);
$sql = "INSERT INTO `users`
(`user_email`,`name`,`user_pass`,`o_pass`, `timestamp`) VALUES
( '$user_email','$user_name', '$hash','$pass', current_timestamp())";
$result = mysqli_query($conn, $sql);
if($result){
$showAlert = true;
header("Location: index.php?signupsuccess=true");
exit();
}
}
else{
$showError = "Passwordsdonotmatch";
}
}
header("Location: index.php?signupsuccess=false&error=$showError");
}
?>
a g e | 11
Header.php
<?php
session_start();
<li class="nav-item">
<a class="nav-link" href="contact.php" >Contact</a>
</li>
</ul>
<div class="row mx-2">';
if(isset($_SESSION['loggedin']) && $_SESSION['loggedin']==true){
echo '<form class="form-inline my-2 my-lg-0" method="get"
action="search.php">
<input class="form-control mr-sm-2" name="search" type="search"
placeholder="Search" aria-label="Search">
<button class="btn btn-success my-2 my-sm-0"
type="submit">Search</button>
<p class="text-light my-0 mx-2">Welcome '. $_SESSION['name']. ' </p>
<a href="_logout.php" class="btn btn-outline-success ml-2">Logout</a>
</form>';
}
else{
a g e | 12
echo '</div>
</div>
</nav>';
include '_loginModal.php';
include '_signupModal.php';
if(isset($_GET['signupsuccess']) && $_GET['signupsuccess']=="true"){
echo '<div class="alert alert-success alert-dismissible fade show my-0"
role="alert">
<strong>Success!</strong> You can now login
<button type="button" class="close" data-dismiss="alert" aria-
label="Close">
<span aria-hidden="true">×</span>
</button>
</div>';
}
$signup=$_GET['signupsuccess'];
$error=$_GET['error'];
if($signup=='false' && $error=='Passwordsdonotmatch')
{
echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Sorry!</strong> Your Password is not match!
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>';
a g e | 13
}
if($signup=='false' && $error=='Emailalreadyinuse')
{
echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Sorry!</strong> Email is alrady in use!
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>';
}
if(isset($_GET['user']))
{
$news=$_GET['user'];
if($news=='notfound')
{
echo '<div class="alert alert-danger alert-dismissible fade show"
role="alert">
<strong>Sorry!</strong> Your Account is not found!
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>';
}
if($news=='found')
{
echo '<div class="alert alert-success alert-dismissible fade show"
role="alert">
<strong>Success!</strong> Your are now a logedin!
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>';
}
a g e | 14
?>
Thread.php
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,
shrink-to-fit=no">
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity="sha384-
9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1
dKGj7Sk" crossorigin="anonymous">
<style>
#ques{
min-height: 433px;
}
</style>
<title>Welcome to iDiscuss - Coding Forums</title>
</head>
<body>
<?php include '_dbconnect.php';?>
<?php include '_header.php';?>
<?php
if(!isset($_GET['threadid'])){
echo' <div class="container" style="padding: 0px;
margin: 165px 5px;
text-align: center;">
<a href="index.php" class="btn btn-warning stretched-link">unwanted
request go to index.php</a></div>';
exit;
}
$id = $_GET['threadid'];
$sql = "SELECT * FROM `threads` WHERE thread_id=$id";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_assoc($result)){
$title = $row['thread_title'];
a g e | 15
$desc = $row['thread_desc'];
$thread_user_id = $row['thread_user_id'];
$sql2 = "SELECT user_email FROM `users` WHERE
sno='$thread_user_id'";
$result2 = mysqli_query($conn, $sql2);
$row2 = mysqli_fetch_assoc($result2);
$posted_by = $row2['user_email'];
}
?>
<?php
$showAlert = false;
$method = $_SERVER['REQUEST_METHOD'];
if($method=='POST'){
$comment = $_POST['comment'];
$comment = str_replace("<", "<", $comment);
$comment = str_replace(">", ">", $comment);
$sno = $_POST['sno'];
$sql = "INSERT INTO `comments` ( `comment_content`, `thread_id`,
`comment_by`, `comment_time`) VALUES ('$comment', '$id', '$sno',
current_timestamp())";
$result = mysqli_query($conn, $sql);
$showAlert = true;
if($showAlert){
echo '<div class="alert alert-success alert-dismissible fade show"
role="alert">
<strong>Success!</strong> Your comment has been added!
<button type="button" class="close" data-dismiss="alert" aria-
label="Close">
<span aria-hidden="true">×</span>
</button>
</div>';
}
}
?>
<?php
if(isset($_SESSION['loggedin']) && $_SESSION['loggedin']==true){
echo '<div class="container">
<h1 class="py-2">Post a Comment</h1>
<form action= "'. $_SERVER['REQUEST_URI'] . '" method="post">
<div class="form-group">
<label for="exampleFormControlTextarea1">Type your
comment</label>
<textarea class="form-control" id="comment" name="comment"
rows="3"></textarea>
<input type="hidden" name="sno" value="'. $_SESSION["sno"]. '">
</div>
<button type="submit" class="btn btn-success">Post
Comment</button>
</form>
</div>';
}
else{
echo '
<div class="container">
<h1 class="py-2">Post a Comment</h1>
<p class="lead">You are not logged in. Please login to be able to post
comments.</p>
</div>
';
}
?>
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE
+IbbVYUew+OrCXaRkfj" crossorigin="anonymous">
</script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
a g e | 18
integrity="sha384-
Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMf
ooAo" crossorigin="anonymous">
</script>
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
integrity="sha384-
OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/
kR0JKI" crossorigin="anonymous"> </script></body>
</html>
OUTPUTS
.Home page
Loginmodal
a g e | 19
Signupmodal
Category
a g e | 20
Question discussion
a g e | 21
Searching results
Contact us
Actual Methodology
a g e | 22
Advantages
a g e | 23
Conclusion
From this microproject we learnt about php and how to use database how to access a
database and how-to access a database data to use in website to create a dynamic
website using a php
References
a g e | 24
1 ) geeksforgeeks
2)php.net
3) YOUTUBE
4)WEBSITES