PHP Microprojects 1 by Campusify
PHP Microprojects 1 by Campusify
1513
1530
1537
1538
INDEX
SRNO TOPIC PAGE
NO.
1. Introduction 8
4. Output 32,33
5. Database Table 34
6. Conclusion 35
7. References 35
What is PHP?
PHP (Hypertext Preprocessor) is a widely used open-source scripting
language primarily designed for web development. It is a server-side
scripting language, meaning the code is executed on the server before being
sent to the client's browser, producing dynamic web pages. Originally
created by Danish-Canadian programmer Rasmus Lerdorf in 1994, PHP has
since evolved into one of the most popular programming languages for web
development.
Simplicity:
PHP is known for its ease of use and simplicity, making it an ideal language
for beginners. Its syntax is similar to C and Perl, which makes it familiar to
many programmers.
Open Source:
PHP is open-source software, meaning it is freely available for anyone to
use, modify, and distribute. This has contributed to its widespread adoption
and continuous improvement by a large community of developers.
Platform Independence:
PHP is platform-independent, meaning it can run on various operating
systems like Windows, Linux, macOS, and Unix. This flexibility makes it a
versatile choice for web development projects.
Integration:
PHP seamlessly integrates with various databases, including MySQL,
PostgreSQL, Oracle, and SQLite, allowing developers to build dynamic,
database-driven websites and applications.
Scalability:
PHP is highly scalable, allowing developers to build applications that can
handle a large number of users and data without sacrificing performance.
Security:
While PHP itself is secure, developers need to follow best practices to
ensure the security of their applications. PHP offers features like data
encryption, secure authentication mechanisms, and input validation to help
developers build secure web applications.
Project Introduction
In this project, we are crafting a sophisticated and feature-packed Gym
Management System using the PHP programming language. Our goal is to
provide users with a comprehensive tool capable of handling Gym
operations Our System is user – friendly
Key Features:
1. Member Registration: Allows staff to register new members by collecting
necessary details such as personal information, contact details, health history,
and preferences.
5. Payment Details - Add New: Enables staff to input new payment data, such
as membership fees, installment payments, or one-time purchases, and
updates member accounts accordingly.
6. Trainer Details - View: Shows information about trainers employed by the
gym, including qualifications, specialties, availability, and contact details.
5. Data-Driven Decision Making: The system generates reports and analytics that
provide valuable insights into membership trends, revenue streams, and operational
performance, empowering gym owners to make informed decisions to drive business
growth.
6. Personalized Training: By allowing members to select preferred trainers during
registration and providing trainers with access to member profiles, the system enables
personalized training programs tailored to individual needs and goals.
7. Security and Compliance: The system ensures the security of member data and
compliance with privacy regulations through robust security measures such as user
authentication and data encryption.
8. Scalability and Flexibility : As the gym grows and evolves, the system can be easily
scaled up to accommodate increasing membership numbers and expanded services,
while remaining flexible enough to adapt to changing business requirements.
Overall, the gym management system is indispensable for modern fitness facilities
seeking to streamline operations, enhance member satisfaction, and drive business
success in a competitive market.
Program Code
Index.php:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-
beta/css/bootstrap.min.css" integrity="sha384-
/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M"
crossorigin="anonymous">
</head>
<style type="text/css">
#inputbtn:hover{cursor:pointer;}
</style>
<body style="background:url('images/4.jpg'); background-size: cover;">
<div class="container-fluid" style="margin-top:60px;margin-bottom:60px;color:#34495E;">
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-4">
<div class="card">
<img src="images/cardback.jpg" class="card-img-top">
<div class="card-body">
<center>
<h5>Admin Login</h5><br>
<form class="form-group" method="POST" action="admin-panel.php">
<div class="row">
<div class="col-md-4"><label>Username: </label></div>
<div class="col-md-8"><input type="text" name="username" class="form-control"
placeholder="enter username" required/></div><br><br>
<div class="col-md-4"><label>Password: </label></div>
<div class="col-md-8"><input type="password" class="form-control"
name="password" placeholder="enter password" required/></div><br><br><br>
</div>
<center><input type="submit" id="inputbtn" name="login_submit" value="Login"
class="btn btn-primary"></center>
</form>
</center>
</div>
</div>
</div>
<div class="col-md-7"></div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<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.11.0/umd/popper.min.js"
integrity="sha384-
b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"
integrity="sha384-
h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1"
crossorigin="anonymous"></script>
</body>
</html>
Admin-panel.php:
<!DOCTYPE html>
<?php
$hostname = "localhost";
$username = "root";
$password = "";
$databaseName = "loginsystem";
// for method 1
</select>
<input type="submit" class="btn btn-primary" name="pat_submit" value="Register"> <a
href="func.php" class="btn btn-light"></a>
</form>
</div>
</div>
</div>
<div class="col-md-1"></div>
</div>
<header>
<nav>
<div class="main-wrapper">
<div class="nav-login">
<?php
if (isset($_SESSION['u_id'])) {
echo '<form action="includes/index.php" method="POST">
<button type="submit" name="submit">logout</button>
</form>';
} else{
echo '<form action="includes/index.php"
method="POST">
</form>
<a href="index.php" class="btn btn-light" style="background-
color:#3498DB;color:FFFFFF">Logout</a>';
}?>
</div>
</div>
</nav>
</header>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"
integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1"
crossorigin="anonymous"></script>
</body>
</html>
Func.php:
<?php
$con=mysqli_connect("localhost","root","","loginsystem");
if(isset($_POST['login_submit'])){
$username=$_POST['username'];
$password=$_POST['password'];
$query="select * from logintb where username='$username' and password='$password'";
$result=mysqli_query($con,$query);
if(mysqli_num_rows($result)==1)
{
header("Location:admin-panel.php");
}
else
{
echo "<script>alert('error login')</script>";
echo "<script>window.open('admin-panel.php','_self')</script>";
}
}
if(isset($_POST['pat_submit']))
{
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$email=$_POST['email'];
$contact=$_POST['contact'];
$docapp=$_POST['docapp'];
$query="insert into
doctorapp(fname,lname,email,contact,docapp)values('$fname','$lname','$email','$contact','$docapp')";
$result=mysqli_query($con,$query);
if($result)
{
echo "<script>alert('Member added.')</script>";
echo "<script>window.open('admin-panel.php','_self')</script>";
}
}
if(isset($_POST['tra_submit']))
{
$Trainer_id=$_POST['Trainer_id'];
$Name=$_POST['Name'];
$phone=$_POST['phone'];
$query="insert into Trainer(Trainer_id,Name,phone)values('$Trainer_id','$Name','$phone')";
$result=mysqli_query($con,$query);
if($result)
{
echo "<script>alert('Trainer added.')</script>";
echo "<script>window.open('admin-panel.php','_self')</script>";
}
}
if(isset($_POST['pay_submit']))
{
$Payment_id=$_POST['Payment_id'];
$Amount=$_POST['Amount'];
$customer_id=$_POST['customer_id'];
$payment_type=$_POST['payment_type'];
$customer_name=$_POST['customer_name'];
$query="insert into
Payment(Payment_id,Amount,customer_id,payment_type,customer_name)values('$Payment_id','$Amount
','$customer_id','$payment_type','$customer_name')";
$result=mysqli_query($con,$query);
if($result)
{
echo "<script>alert('Payment sucessfull.')</script>";
echo "<script>window.open('admin-panel.php','_self')</script>";
}
}
function
get_patient_details(){ global
$con;
$query="select * from doctorapp";
$result=mysqli_query($con,$query);
while ($row=mysqli_fetch_array($result)){
$fname=$row ['fname'];
$lname=$row['lname'];
$email=$row['email'];
$contact=$row['contact'];
$docapp=$row['docapp'];
echo "<tr>
<td>$fname</td>
<td>$lname</td>
<td>$email</td>
<td>$contact</td>
<td>$docapp</td>
</tr>";
}
}
function
get_package(){ global
$con;
$query="select * from Package";
$result=mysqli_query($con,$query);
while($row=mysqli_fetch_array($result)){
$Package_id=$row ['Package_id'];
$Package_name=$row['Package_name'];
$Amount=$row['Amount'];
echo"<tr>
<td>$Package_id</td>
<td>$Package_name</td>
<td>$Amount</td>
</tr>";
}
}
function
get_trainer(){ global
$con;
$query="select * from Trainer";
$result=mysqli_query($con,$query);
while($row=mysqli_fetch_array($result)){
$Trainer_id=$row ['Trainer_id'];
$Name=$row['Name'];
$phone=$row['phone'];
echo"<tr>
<td>$Trainer_id</td>
<td>$Name</td>
<td>$phone</td>
</tr>";
}
}
function
get_payment(){ global
$con;
$query="select * from Payment";
$result=mysqli_query($con,$query);
while($row=mysqli_fetch_array($result)){
$Payment_id=$row ['Payment_id'];
$Amount=$row['Amount'];
$payment_type=$row['payment_type'];
$customer_id=$row['customer_id'];
/*$customer_name=$row['customer_name'];*/
echo"<tr>
<td>$Payment_id</td>
<td>$Amount</td>
<td>$payment_type</td>
<td>$customer_id</td>
</tr>";
}
}
?>
Pacakge.php:
<!DOCTYPE html>
<?php include("func.php");?>
<html>
<head>
<title>Members details</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-
beta/css/bootstrap.min.css" integrity="sha384-
/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M"
crossorigin="anonymous">
</head>
<body>
<div class="jumbotron" style="background: url('images/2.jpg') no-repeat;background-size:
cover;height: 300px;"></div>
<div class="container">
<div class="card">
<div class="card-body" style="background-color:#3498DB;color:#ffffff;">
<div class="row">
<div class="col-md-1">
<a href="admin-panel.php" class="btn btn-light ">Go Back</a>
</div>
<div class="col-md-3"><h3>Pcakage Details</h3></div>
<div class="col-md-8">
<form class="form-group" action="patient_search.php" method="post">
<div class="row">
</form></div></div></div>
<div class="card-body" style="background-color:#3498DB;color:#ffffff;">
<div class="card-body">
<table class="table table-hover">
<thead>
<tr>
<th>Package ID </th>
<th>Package Name</th>
<th>Amounts</th>
</tr>
</thead>
<tbody>
<?php get_package(); ?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"
integrity="sha384-
h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1"
crossorigin="anonymous"></script>
</div>
</body>
</html>
Payment.php:
<!DOCTYPE html>
<?php include("func.php");?>
<html>
<head>
<title>Members details</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-
beta/css/bootstrap.min.css" integrity="sha384-
/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M"
crossorigin="anonymous">
</head>
<body>
<div class="jumbotron" style="background: url('images/2.jpg') no-repeat;background-size:
cover;height: 300px;"></div>
<div class="container">
<div class="card">
<div class="card-body" style="background-color:#3498DB;color:#ffffff;">
<div class="row">
<div class="col-md-1">
<a href="admin-panel.php" class="btn btn-light ">Go Back</a>
</div>
<div class="col-md-3"><h3>Payment Details</h3></div>
<div class="col-md-8">
<form class="form-group" action="patient_search.php" method="post">
<div class="row">
</form></div></div></div>
<div class="card-body" style="background-color:#3498DB;color:#ffffff;">
<div class="card-body">
<table class="table table-hover">
<thead>
<tr>
<th>Payment ID </th>
<th>Amount</th>
<th>Payment Type</th>
<th>Customer ID</th>
<!-- <th>Customer Name</th>-->
</tr>
</thead>
<tbody>
<?php get_payment(); ?>
</tbody>
</table>
<div class="card-body" style="background-color:#3498DB;color:FFFFFF;">
<h3>Make new Payment</h3>
</div>
<div class="card-body"></div>
<form class="form-group" action="func.php" method="post">
<label> Customer Name</label>
<input type="text" name="customer_name" class="form-control">
<label>Payment ID</label>
<input type="text" name="Payment_id" class="form-control"><br>
<label>Amount</label>
<input type="text" name="Amount" class="form-control"><br>
<label>Customer ID</label>
<input type="text" name="customer_id" class="form-control"><br>
<!-- <label>Customer Name</label>
<input type="text" name="customer_name" class="form-control"><br>-->
<label>Payment Type</label>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"
integrity="sha384-
h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1"
crossorigin="anonymous"></script>
</div>
</body>
</html>
Signup.php:
<?php
include_once 'header.php';
?>
<section class="main-container">
<div class="main-wrapper">
<h2>signup</h2>
<form class="signup-form" action="includes/signup.inc.php" method="POST">
<input type="text" name="first" placeholder="firstname">
<input type="text" name="last" placeholder="lastname">
<input type="text" name="email" placeholder="e-mail">
<input type="text" name="uid" placeholder="username">
background-color: #ccc;
}
header .nav-login a
{ display: block;
width:30px;
height: 30px;
border: none;
float: left;
background-color: #fff;
font-family: arial;
font-size: 16px;
color: #111;
line-height: 63px;
cursor: pointer;
}
.main-
container{ padding
-top: 40px;
}
Trainer_details.php
<!DOCTYPE html>
<?php include("func.php");?>
<html>
<head>
<title>Members details</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-
beta/css/bootstrap.min.css" integrity="sha384-
/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
</head>
<body>
<div class="jumbotron" style="background: url('images/2.jpg') no-repeat;background-size: cover;height:
300px;"></div>
<div class="container">
<div class="card">
<div class="card-body" style="background-color:#3498DB;color:#ffffff;">
<div class="row">
<div class="col-md-1">
<a href="admin-panel.php" class="btn btn-light ">Go Back</a>
</div>
<div class="col-md-3"><h3>Members Details</h3></div>
<div class="col-md-8">
<form class="form-group" action="trainer_search.php" method="post">
<div class="row">
<div class="col-md-10"><input type="text" name="search" class="form-control" placeholder="enter
contact"></div>
<div class="col-md-2"><input type="submit" name="patient_search_submit" class="btn btn-light"
value="Search"> </div></div>
</form></div></div></div>
<div class="card-body" style="background-color:#3498DB;color:#ffffff;">
<div class="card-body">
<table class="table table-hover">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email id</th>
<th>Member ID</th>
<th>Trainer ID</th>
</tr>
</thead>
<tbody>
<?php get_patient_details(); ?>
</tbody>
</table>
</div>
</div>
</div) >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-
h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1"
crossorigin="anonymous"></script>
</div>
</body>
</html>
Trainer_search.php
<html>
<head>
<title>Patient details</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-
beta/css/bootstrap.min.css" integrity="sha384-
/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
</head>
<body>
<?php
include("func.php");
if(isset($_POST['patient_search_submit']))
{
$contact=$_POST['search'];
$query="select * from doctorapp where contact='$contact'";
$result=mysqli_query($con,$query);
echo "<div class='container-fluid' style='margin-top:50px;'>
<div class'card'>
<div class='card-body'><a href='trainer_details.php' class='btn brn-light'>Go Back</a></div>
<img src='images/1.jpg'>
<table class='table table-hover'>
<thead>
<tr>
<th>First name</th>
<th>Last name</th>
<th>Email id</th>
<th>Contact</th>
<th>Trainer ID</th>
</tr>
</thead>
<tbody>
</div></div>";
while ($row=mysqli_fetch_array($result)){
$fname=$row ['fname'];
$lname=$row['lname'];
$email=$row['email'];
$contact=$row['contact'];
$docapp=$row ['docapp'];
echo " <tr>
<td>$fname</td>
<td>$lname</td>
<td>$email</td>
<td>$contact</td>
<td>$docapp</td>
</tr>";
}
echo "</tbody></table></div></div></div>";
}
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-
h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1"
crossorigin="anonymous"></script>
</body>
</html>
Trainer.php
<!DOCTYPE html>
<?php include("func.php");?>
<html>
<head>
<title>Members details</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-
beta/css/bootstrap.min.css" integrity="sha384-
/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
</head>
<body>
<div class="jumbotron" style="background: url('images/2.jpg') no-repeat;background-size: cover;height:
300px;"></div>
<div class="container">
<div class="card">
<div class="card-body" style="background-color:#3498DB;color:#ffffff;">
<div class="row">
<div class="col-md-1">
<a href="admin-panel.php" class="btn btn-light ">Go Back</a>
</div>
<div class="col-md-3"><h3> Trainer Information</h3></div>
<div class="col-md-8">
<form class="form-group" action="patient_search.php" method="post">
<div class="row">
</form></div></div></div>
<div class="card-body" style="background-color:#3498DB;color:#ffffff;">
<div class="card-body">
<table class="table table-hover">
<thead>
<tr>
<th>Trainer ID</th>
<th>Name</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<?php get_trainer(); ?>
</tbody>
</table>
<div class="card-body" style="background-color:#3498DB;color:FFFFFF;">
<h3>Register new Trainer</h3>
</div>
<div class="card-body"></div>
<form class="form-group" action="func.php" method="post">
<label>Trainer ID</label>
<input type="text" name="Trainer_id" class="form-control"><br>
<label>Name</label>
<input type="text" name="Name" class="form-control"><br>
<label>Phone</label>
<input type="text" name="phone" class="form-control"><br>
<input type="submit" class="btn btn-primary" name="tra_submit" value="Register">
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-
h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1"
crossorigin="anonymous"></script>
</div>
</body>
</html>
Dbh.inc.php:
<?php
$dbServername = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName = "loginsystem";
Reference
www.google.com
www.campusify.co.in