0% found this document useful (0 votes)
8 views4 pages

Database Project Report

ejnfie

Uploaded by

MHA MIRZA Gaming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Database Project Report

ejnfie

Uploaded by

MHA MIRZA Gaming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Name: Muhammad Shazil Khan

Reg No: 230201041


Batch: CS-04A
Database Project Report

Overview

The Hospital Database Management System is a web-based application designed to facilitate


patient management and appointments in a hospital setting. The system provides functionalities
for users to sign in, sign up, book appointments, and access information about the hospital. The
backend of the application is built using Flask, a lightweight web framework for Python, and the
database operations are handled using MySQL.

Key Features

1. User Authentication: The system allows users to sign up and sign in. It checks for
existing users during sign-up and validates credentials during sign-in.
2. Appointment Booking: Users can book appointments by providing their details and a
message describing their requirements.
3. User Session Management: The application manages user sessions to keep track of
logged-in users and allows them to log out when done.
4. Information Pages: The application includes static information pages such as a
homepage and an about page.
5. Database Schema
 Users Table: Stores user details including first name, last name, email, and
password.
 Appointments Table: Stores appointment details including the user's full name,
email, phone number, and message.
6. Flask Routes and Functionality
 Home Route (/home): Renders the homepage.
 Sign-in Route (/): Handles user login. Validates user credentials against the
database and redirects to the homepage upon successful login.
 Sign-up Route (/signup): Handles user registration. Checks for existing users
and inserts new user details into the database.
 Logout Route (/logout): Manages user logout and session clearing.
 About Route (/about): Renders the about page.
 Appointment Route (/appointment): Handles appointment booking by
inserting appointment details into the database.
7. Database Connection

conn = mysql.connector.connect(host="localhost", password="23august",


user="root", database="hospital")
cursor = conn.cursor()

8. Flask Application Setup

app = Flask(__name__)
app.secret_key = 'your secret key'

9. User Sign-In

@app.route("/", methods=['post', 'get'])


def signin():
msg = ''
if request.method == 'POST':
L_email = request.form['login_email']
L_pwd = request.form['login_pwd']
cursor.execute("SELECT * FROM users WHERE email=%s AND
password=%s", (L_email, L_pwd))
record = cursor.fetchone()
if L_email == '' or L_pwd == '':
msg = 'All Fields are Required'
elif record:
return redirect(url_for('homepage'))
else:
msg = 'Incorrect Username/Password'
return render_template("signin.html", msg=msg)

10. User Sign-Up

@app.route("/signup", methods=['post', 'get'])


def signup():
signup_msg = ''
if request.method == 'POST':
First_name = request.form['f_name']
Last_name = request.form['l_name']
Email = request.form['signup_email']
Pwd = request.form['password']
cursor.execute("SELECT * FROM users WHERE email=%s", [Email])
data = cursor.fetchone()
if First_name == '' or Email == '' or Pwd == '':
signup_msg = 'All Fields are Required'
elif data:
signup_msg = 'This User Already Exist'
else:
cursor.execute("INSERT INTO users (firstname, lastname,
email, password) VALUES (%s, %s, %s, %s)", (First_name, Last_name,
Email, Pwd))
conn.commit()
return redirect(url_for('homepage'))
return render_template("signup.html", msg=signup_msg)

11. Booking an Appointment

@app.route("/appointment", methods=['post', 'get'])


def Appointment():
conn = mysql.connector.connect(host="localhost",
password="23august", user="root", database="hospital")
cursor = conn.cursor()
msg = ''
if request.method == 'POST':
Fullname = request.form['fullname']
Appointment_Email = request.form['A_email']
Phonenumber = request.form['phonenumber']
Message = request.form['message']
if Fullname == '' or Appointment_Email == '' or Phonenumber ==
'' or Message == '':
msg = 'All Fields are Required'
else:
cursor.execute("INSERT INTO appointment (fullname, email,
phonenumber, message) VALUES (%s, %s, %s, %s)", (Fullname,
Appointment_Email, Phonenumber, Message))
conn.commit()
msg = 'Successfully Appointed'
return render_template('appointment.html', msg=msg)

12. Logout and Session Management

@app.route("/logout")
def logout():
session.pop('loggin', None)
session.pop('username', None)
return redirect(url_for('signin'))

Considerations and Future Enhancements

 Security Enhancements: Passwords should be hashed using a secure algorithm like


bcrypt before storing them in the database.
 Input Validation: Implement more robust input validation to prevent SQL injection and
other forms of attacks.
 Error Handling: Improve error handling to gracefully manage database connection
issues and other runtime errors.
 User Experience: Enhance the user interface for better user experience and accessibility.

This Hospital Database Management System serves as a foundational project for managing
hospital appointments and user authentication. With further enhancements and additional
features, it can be expanded into a comprehensive hospital management system.

You might also like