Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 25

Government Polytechnic Solapur

MICRO-PROJECT
Php(22619)

Forum website
age |1

GOVERMENT POLYTECHNIC, SOLAPUR

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.

Place: SOLAPUR Enrolment No: 1900150267

Date: - - 2022 Exam seat no:

Project Guide H.O.D. Principal


age |2

Abstract

For microproject of Php in third year I chose Forum, Online discussion


forums are asynchronous communication tools that are widely used in Learning
Management Systems. However, instructors and students face various
difficulties, and instructors lack a guide on what strategies they can use to
achieve a more participatory forum environment. This work aims to identify
benefits and difficulties of using online discussion forums from the instructors’
point of view, and to provide a list of strategies and improvements that can
mitigate the challenges and lead to a more participatory forum. We used coding
procedures to analyse data collected through semi-structured interviews. The
results of our exploratory analysis are relevant to the distance learning
community and can inform instructors, developers, and researchers to help them
improve the quality of mediation and use of forums.
age |3

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.

We would also like to express our thankfulness to our beloved Principal


as well as HOD and other faculty members of our Third-year department for
extending their support and motivation

Finally, we completed our micro project that regarding to our syllabus as


well as department, Once more thanks for all Group members, Respected
Principal, HOD and other Faculty Members who helped us in the micro project
completion.
age |4

PART A – Micro-Project Proposal

All in one shopping app

1.0 Brief Introduction


In This micro project we are going develop forum website

2.0 Aim of the Micro-Project (in about 1 to 2 Sentences)


This Micro-Project aims at:
The aim is to develop the skill of creating or developing PHP website. The aim of this Project
is Forum website

3.0 Intended Course Outcomes


 Develop program using control statement. 
 Perform operations based on arrays and graphics.
 Develop programs by applying various object oriented concepts.
 Use form controls with validation to collect user's input.
 Perform database operations in PHP.

4.0 Literature Review


We searched information for the suggested topic by our industry guide. Collected the
data required for the project. We did some experiments to make different models easier to
understand.

5.0 Proposed Methodology


1. First searched information for the suggested micro-project.
2. Collected information for the suggested topic.
3. Started for the micro-project.
4. Completed micro-project.
5. Showed to respected teacher.
6. Teacher suggested some changes.
7. Done the changes into the project as told by teacher.
age |5

6.0 Resources Required.

S. Name of Specifications Qty Remarks


No. Resource/material
1 Computer System I5 12th generation 1 -
16GB RAM
512GB SSD
2 XAMPP - 1 -

3 Chrome 1

7.0 Action Plan (Sequence and time required for major activities for 8 Weeks)

S. No. Details of activity Planned Start Planned


date Finish date

1 Searched for topic of micro-project

2 Topic searched: -

1. game
2. Class management
3. Forum website

3 Discussed with teacher about the topic

4 Teacher approved for All in one shopping app

5 Created prototype of our project

6 Started for making Structure

7 Created well structure

8 Started to collect the required resources

9 Completed all the models

10 Showed models to teacher and she suggested


some changes
age |6

11 We made the changes

12 Guide approved the models

Content Page

Sr. No Chapter No Page No


1 Introduction

2 Aim

3 Resources Used

4 Code o/p

5 Actual Methodology

6 Advantages

7 Conclusion

8 Reference

Introduction
age |7

The term PHP is an acronym for PHP: Hypertext Preprocessor. PHP is a


server-side scripting language designed specifically for web development. It is
open-source which means it is free to download and use. It is very simple to
learn and use. The files have the extension “.php”. 

For microproject of php in third year I chose online forum website


because
A forum is an online discussion board where people can ask questions, share
their experiences, and discuss topics of mutual interest. Forums are an excellent
way to create social connections and a sense of community. They can also help
you to cultivate an interest group about a particular subject.

Aim

 Interpret features of PHP web development.


 Configure Android environment and development tools.
 Develop rich user Interfaces by using layouts and controls.
 Use User Interface components for PHP web development.
 Publish PHP website.
age |8

Resources Used and Requirements

Development Resources Used

HARDWARE

CPU INTEL CORE I5 2ND GEN

RAM 8GB

DISK REQUIRED 50GB

CLOCKS SPEED 2.8 GHz AND 3.5 GHz

SOFTWARE

XAMPP 7.4.29

Google chorme 103.0.5055.0

Coding and outputs

_dbconn.php

<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "idiscuss";
$conn = mysqli_connect($servername, $username, $password, $database);
?>
age |9

_footer.php

<div class="container-fluid bg-dark text-light">


<p class="text-center m-0">Copyright iDiscuss Coding Forums 2022 | All
rights reserved</p>
</div>
_handlelogin.php

<?php
$showError = "false";
if($_SERVER["REQUEST_METHOD"] == "POST"){
include '_dbconnect.php';
$email = $_POST['loginEmail'];
$pass = $_POST['loginPass'];

$sql = "Select * from users where user_email='$email'";


$result = mysqli_query($conn, $sql);
$numRows = mysqli_num_rows($result);
if($numRows==1){
$row = mysqli_fetch_assoc($result);
if(password_verify($pass, $row['user_pass'])){
session_start();

$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();

echo '<nav class="navbar navbar-expand-lg navbar-dark bg-dark">


<a class="navbar-brand" href="/forum">iDiscuss</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-
target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">


<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="/forum">Home <span class="sr-
only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.php">About</a>
</li>

<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 '<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>
</form>
<button class="btn btn-outline-success ml-2" data-toggle="modal" data-
target="#loginModal">Login</button>
<button class="btn btn-outline-success mx-2" data-toggle="modal" data-
target="#signupModal">Signup</button>';
}

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">&times;</span>
</button>
</div>';
}

if(isset($_GET['signupsuccess']) && isset($_GET['error']) ){

$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">&times;</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">&times;</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">&times;</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">&times;</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("<", "&lt;", $comment);
$comment = str_replace(">", "&gt;", $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">&times;</span>
</button>
</div>';
}
}
?>

<div class="container my-4">


<div class="jumbotron">
<h1 class="display-4"><?php echo $title;?></h1>
<p class="lead"> <?php echo $desc;?></p>
<hr class="my-4">
a g e | 16

<p>This is a peer to peer forum. No Spam / Advertising / Self-promote


in the forums is not allowed. Do not post copyright-infringing material. Do not
post “offensive” posts, links or images. Do not cross post questions. Remain
respectful of other members at all times.</p>
<p>Posted by: <em><?php echo $posted_by; ?></em></p>
</div>
</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>
';
}

?>

<div class="container mb-5" id="ques">


<h1 class="py-2">Discussions</h1>
<?php
$id = $_GET['threadid'];
a g e | 17

$sql = "SELECT * FROM `comments` WHERE thread_id=$id";


$result = mysqli_query($conn, $sql);
$noResult = true;
while($row = mysqli_fetch_assoc($result)){
$noResult = false;
$id = $row['thread_id'];
$content = $row['comment_content'];
$comment_time = $row['comment_time'];
$thread_user_id = $row['comment_by'];

$sql2 = "SELECT user_email FROM `users` WHERE


sno='$thread_user_id'";
$result2 = mysqli_query($conn, $sql2);
$row2 = mysqli_fetch_assoc($result2);

echo '<div class="media my-3">


<img src="userdefault.jpg" width="54px" class="mr-3" alt="...">
<div class="media-body">
<p class="font-weight-bold my-0">'. $row2['user_email'] .' at '.
$comment_time. '</p> '. $content . '
</div>
</div>';
}
if($noResult){
echo '<div class="jumbotron jumbotron-fluid">
<div class="container">
<p class="display-4">No Comments Found</p>
<p class="lead"> Be the first person to comment</p>
</div>
</div> ';
}
?>
</div>
<?php include '_footer.php';?>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"

integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE
+IbbVYUew+OrCXaRkfj" crossorigin="anonymous">
</script>
<script
src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/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

1. First searched information for the suggested micro-project.


2. Collected information for the suggested topic.
3. Started for the micro-project.
4. Completed micro-project.
5. Showed to respected teacher.
6. Teacher suggested some changes.
7. Done the changes into the project as told by teacher.

Advantages
a g e | 23

Following are advantages of online forum website


1. It helps you build new relationships.
2. It helps you get a new perspective and immediate feedback.
3. You can get help and support.
4. It helps build brand awareness.
5. It improves communication and performance in people.

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

You might also like