This commit is contained in:
Flatlogic Bot 2025-10-15 18:48:09 +00:00
parent 8087be84b0
commit e59c8581a5
13 changed files with 1956 additions and 144 deletions

140
admin-registration.php Normal file
View File

@ -0,0 +1,140 @@
<?php
session_start();
require_once 'db/config.php';
$message = '';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
try {
$pdo = db();
// Create admins table if it doesn't exist
$pdo->exec("CREATE TABLE IF NOT EXISTS admins (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role ENUM('admin', 'superadmin') NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)");
$name = $_POST['name'];
$email = $_POST['email'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
$role = $_POST['role'];
// Check if email already exists
$stmt = $pdo->prepare("SELECT id FROM admins WHERE email = ?");
$stmt->execute([$email]);
if ($stmt->fetch()) {
$message = '<div class="alert alert-danger">Error: An account with this email already exists.</div>';
} else {
$sql = "INSERT INTO admins (name, email, password, role) VALUES (?, ?, ?, ?)";
$stmt = $pdo->prepare($sql);
if ($stmt->execute([$name, $email, $password, $role])) {
$message = '<div class="alert alert-success">Admin user created successfully! You can now log in. For security, please consider removing this registration file.</div>';
} else {
$message = '<div class="alert alert-danger">Error: Could not create admin user.</div>';
}
}
} catch (PDOException $e) {
$message = '<div class="alert alert-danger">Database error: ' . $e->getMessage() . '</div>';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Registration - Medicaltour</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">Medicaltour</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="index.php#about">About</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#services">Services</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#packages">Packages</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#testimonials">Testimonials</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#contact">Contact</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownRegister" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Register
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownRegister">
<li><a class="dropdown-item" href="patient-registration.php">Patient</a></li>
<li><a class="dropdown-item" href="doctor-registration.php">Doctor</a></li>
<li><a class="dropdown-item" href="hospital-registration.php">Hospital</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- Page Content -->
<main class="container mt-5 pt-5">
<section id="admin-registration" class="py-5">
<div class="row justify-content-center">
<div class="col-md-6">
<h2 class="mb-4 text-center">Admin Registration</h2>
<p class="text-center text-muted">Create a new Admin or Superadmin account. This page should be deleted after use.</p>
<?php if (!empty($message)) echo $message; ?>
<form action="admin-registration.php" method="post" class="needs-validation" novalidate>
<div class="mb-3">
<label for="name" class="form-label">Full Name</label>
<input type="text" class="form-control" id="name" name="name" required>
<div class="invalid-feedback">Please enter your full name.</div>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email Address</label>
<input type="email" class="form-control" id="email" name="email" required>
<div class="invalid-feedback">Please enter a valid email address.</div>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
<div class="invalid-feedback">Please enter a password.</div>
</div>
<div class="mb-3">
<label for="role" class="form-label">Role</label>
<select class="form-select" id="role" name="role" required>
<option value="" disabled selected>Select a role</option>
<option value="admin">Admin</option>
<option value="superadmin">Superadmin</option>
</select>
<div class="invalid-feedback">Please select a role.</div>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary">Create Admin User</button>
</div>
</form>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="py-5 bg-dark text-white">
<div class="container text-center">
<p>&copy; 2025 Medicaltour. All Rights Reserved.</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>

27
assets/css/custom.css Normal file
View File

@ -0,0 +1,27 @@
body {
background-color: #F8F9FA;
}
.navbar {
background-color: #FFFFFF;
box-shadow: 0 2px 4px rgba(0,0,0,.1);
}
.section {
padding: 60px 0;
}
.hero {
background: linear-gradient(to right, #0D6EFD, #198754);
color: white;
padding: 100px 0;
}
.hero h1 {
font-weight: 700;
}
.btn-accent {
background-color: #198754;
color: white;
}

9
assets/js/main.js Normal file
View File

@ -0,0 +1,9 @@
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});

227
dashboard.php Normal file
View File

@ -0,0 +1,227 @@
<?php
session_start();
require_once 'db/config.php';
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_SESSION['user_role']) && $_SESSION['user_role'] == 'doctor' && isset($_POST['availability'])) {
try {
$db = db();
$doctorId = $_SESSION['user_id'];
$availability = $_POST['availability'];
$stmt = $db->prepare("UPDATE doctors SET availability = ? WHERE id = ?");
$stmt->execute([$availability, $doctorId]);
header("Location: dashboard.php"); // Redirect to avoid form resubmission
exit;
} catch (PDOException $e) {
// For simplicity, we are not displaying the error here. In a real application, you would log this.
}
}
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
$userName = $_SESSION['user_name'] ?? 'User';
$userRole = $_SESSION['user_role'] ?? 'guest';
// Content for different roles
$dashboardContent = '';
switch ($userRole) {
case 'superadmin':
$dashboardContent = '<p>Here you can manage the entire application, including admins, hospitals, doctors, and patients.</p>';
break;
case 'admin':
$dashboardContent = '<p>Here you can manage hospitals, doctors, and patients.</p>';
break;
case 'hospital':
$dashboardContent = '
<p>Here you can manage your hospital profile, treatments, and doctors.</p>
<div class="list-group">
<a href="hospital-treatments.php" class="list-group-item list-group-item-action">Manage Treatment Categories</a>
<a href="hospital-doctors.php" class="list-group-item list-group-item-action">Manage Doctors</a>
</div>
';
break;
case 'doctor':
$db = db();
$doctorId = $_SESSION['user_id'];
// Fetch doctor's complete profile
$stmt = $db->prepare("SELECT d.full_name, d.email, d.specialty, d.qualifications, d.specialities, d.contact_phone, d.license_number, d.consultation_fee, d.availability, h.hospital_name, h.address, h.city, h.state, h.country FROM doctors d LEFT JOIN hospitals h ON d.hospital_id = h.id WHERE d.id = ?");
$stmt->execute([$doctorId]);
$doctor = $stmt->fetch(PDO::FETCH_ASSOC);
$profileInfo = '<div class="card mb-4"><div class="card-body"><h5 class="card-title">My Profile</h5>';
if ($doctor) {
$profileInfo .= '<p class="card-text"><strong>Name:</strong> '.htmlspecialchars($doctor['full_name']).'</p>';
$profileInfo .= '<p class="card-text"><strong>Email:</strong> '.htmlspecialchars($doctor['email']).'</p>';
$profileInfo .= '<p class="card-text"><strong>Contact Phone:</strong> '.htmlspecialchars($doctor['contact_phone']).'</p>';
$profileInfo .= '<p class="card-text"><strong>Primary Specialty:</strong> '.htmlspecialchars($doctor['specialty']).'</p>';
$profileInfo .= '<p class="card-text"><strong>Additional Specialities:</strong> '.nl2br(htmlspecialchars($doctor['specialities'])).'</p>';
$profileInfo .= '<p class="card-text"><strong>Qualifications:</strong> '.nl2br(htmlspecialchars($doctor['qualifications'])).'</p>';
$profileInfo .= '<p class="card-text"><strong>License Number:</strong> '.htmlspecialchars($doctor['license_number']).'</p>';
$profileInfo .= '<p class="card-text"><strong>Consultation Fee:</strong>
case 'patient':
$dashboardContent = '<p>Here you can manage your profile, view your medical history, and book appointments.</p>';
break;
default:
$dashboardContent = '<p>Welcome to your dashboard.</p>';
break;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard - Medicaltour</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">Medicaltour</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
</ul>
</div>
</div>
</nav>
<!-- Page Content -->
<main class="container mt-5 pt-5">
<section id="dashboard" class="py-5">
<div class="row">
<div class="col-12">
<h2 class="mb-4">Welcome, <?php echo htmlspecialchars($userName); ?>!</h2>
<p class="text-muted">Your role: <span class="badge bg-primary"><?php echo htmlspecialchars(ucfirst($userRole)); ?></span></p>
<hr>
<div class="dashboard-content">
<?php echo $dashboardContent; ?>
</div>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="py-5 bg-dark text-white mt-auto">
<div class="container text-center">
<p>&copy; 2025 Medicaltour. All Rights Reserved.</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>.htmlspecialchars($doctor['consultation_fee']).'</p>';
$profileInfo .= '<p class="card-text"><strong>Availability:</strong> '.nl2br(htmlspecialchars($doctor['availability'])).'</p>';
} else {
$profileInfo .= '<p class="card-text">Profile not found.</p>';
}
$profileInfo .= '</div></div>';
// Fetch hospital info
$hospitalInfo = '<div class="card mb-4"><div class="card-body"><h5 class="card-title">My Hospital</h5>';
if ($doctor && $doctor['hospital_name']) {
$hospitalInfo .= '<p class="card-text">'.htmlspecialchars($doctor['hospital_name']).'</p>';
$hospitalInfo .= '<p class="card-text">'.htmlspecialchars($doctor['address']).', '.htmlspecialchars($doctor['city']).', '.htmlspecialchars($doctor['state']).', '.htmlspecialchars($doctor['country']).'</p>';
} else {
$hospitalInfo .= '<p class="card-text">You are not currently affiliated with any hospital.</p>';
}
$hospitalInfo .= '</div></div>';
// Fetch patient history
$stmt = $db->prepare("SELECT p.full_name, a.appointment_date, a.notes FROM patients p JOIN appointments a ON p.id = a.patient_id WHERE a.doctor_id = ? ORDER BY a.appointment_date DESC");
$stmt->execute([$doctorId]);
$appointments = $stmt->fetchAll(PDO::FETCH_ASSOC);
$patientHistory = '<div class="card"><div class="card-body"><h5 class="card-title">Patient History</h5>';
if ($appointments) {
$patientHistory .= '<ul class="list-group list-group-flush">';
foreach ($appointments as $appointment) {
$patientHistory .= '<li class="list-group-item">'.htmlspecialchars($appointment['full_name']).' - '.(new DateTime($appointment['appointment_date']))->format('m/d/Y').'<br><small>'.htmlspecialchars($appointment['notes']).'</small></li>';
}
$patientHistory .= '</ul>';
} else {
$patientHistory .= '<p class="card-text">No patient history found.</p>';
}
$patientHistory .= '</div></div>';
$dashboardContent = $profileInfo . $hospitalInfo . $patientHistory;
break;
case 'patient':
$dashboardContent = '<p>Here you can manage your profile, view your medical history, and book appointments.</p>';
break;
default:
$dashboardContent = '<p>Welcome to your dashboard.</p>';
break;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard - Medicaltour</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">Medicaltour</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
</ul>
</div>
</div>
</nav>
<!-- Page Content -->
<main class="container mt-5 pt-5">
<section id="dashboard" class="py-5">
<div class="row">
<div class="col-12">
<h2 class="mb-4">Welcome, <?php echo htmlspecialchars($userName); ?>!</h2>
<p class="text-muted">Your role: <span class="badge bg-primary"><?php echo htmlspecialchars(ucfirst($userRole)); ?></span></p>
<hr>
<div class="dashboard-content">
<?php echo $dashboardContent; ?>
</div>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="py-5 bg-dark text-white mt-auto">
<div class="container text-center">
<p>&copy; 2025 Medicaltour. All Rights Reserved.</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>

97
doctor-profile.php Normal file
View File

@ -0,0 +1,97 @@
<?php
require_once 'db/config.php';
$doctor = null;
$error_message = '';
if (isset($_GET['id'])) {
try {
$db = db();
$doctorId = $_GET['id'];
$stmt = $db->prepare("SELECT d.full_name, d.email, d.specialty, d.qualifications, d.specialities, d.contact_phone, d.license_number, d.consultation_fee, d.availability, h.hospital_name, h.address, h.city, h.state, h.country FROM doctors d LEFT JOIN hospitals h ON d.hospital_id = h.id WHERE d.id = ?");
$stmt->execute([$doctorId]);
$doctor = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$doctor) {
$error_message = "Doctor not found.";
}
} catch (PDOException $e) {
$error_message = "Database error: " . $e->getMessage();
}
} else {
$error_message = "No doctor ID provided.";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Doctor Profile - Medicaltour</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">Medicaltour</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
<li class="nav-item"><a class="nav-link" href="login.php">Login</a></li>
<li class="nav-item"><a class="nav-link" href="patient-registration.php">Register</a></li>
</ul>
</div>
</div>
</nav>
<!-- Page Content -->
<main class="container mt-5 pt-5">
<section id="doctor-profile" class="py-5">
<div class="row">
<div class="col-md-8 mx-auto">
<?php if ($error_message): ?>
<div class="alert alert-danger"><?php echo $error_message; ?></div>
<?php elseif ($doctor): ?>
<div class="card">
<div class="card-body">
<h2 class="card-title text-center mb-4"><?php echo htmlspecialchars($doctor['full_name']); ?></h2>
<p class="card-text"><strong>Primary Specialty:</strong> <?php echo htmlspecialchars($doctor['specialty']); ?></p>
<p class="card-text"><strong>Qualifications:</strong> <?php echo nl2br(htmlspecialchars($doctor['qualifications'])); ?></p>
<p class="card-text"><strong>Additional Specialities:</strong> <?php echo nl2br(htmlspecialchars($doctor['specialities'])); ?></p>
<p class="card-text"><strong>Contact Phone:</strong> <?php echo htmlspecialchars($doctor['contact_phone']); ?></p>
<p class="card-text"><strong>Consultation Fee:</strong> $<?php echo htmlspecialchars($doctor['consultation_fee']); ?></p>
<p class="card-text"><strong>Availability:</strong> <?php echo nl2br(htmlspecialchars($doctor['availability'])); ?></p>
<?php if ($doctor['hospital_name']): ?>
<hr>
<h4>Affiliated Hospital</h4>
<p><?php echo htmlspecialchars($doctor['hospital_name']); ?></p>
<p><?php echo htmlspecialchars($doctor['address']); ?>, <?php echo htmlspecialchars($doctor['city']); ?>, <?php echo htmlspecialchars($doctor['state']); ?>, <?php echo htmlspecialchars($doctor['country']); ?></p>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="py-5 bg-dark text-white mt-auto">
<div class="container text-center">
<p>&copy; 2025 Medicaltour. All Rights Reserved.</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>

237
doctor-registration.php Normal file
View File

@ -0,0 +1,237 @@
<?php
session_start();
require_once 'db/config.php';
$success_message = '';
$error_message = '';
$hospitals = [];
try {
$pdo = db();
// Fetch hospitals for the dropdown
$stmt = $pdo->query("SELECT id, hospital_name as name FROM hospitals ORDER BY name");
$hospitals = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
// If hospitals table doesn't exist, we can proceed without it
if ($e->getCode() !== '42S02') {
$error_message = "Database error: " . $e->getMessage();
}
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
try {
$pdo = db();
// Ensure doctors table is up-to-date
$pdo->exec("CREATE TABLE IF NOT EXISTS doctors (
id INT AUTO_INCREMENT PRIMARY KEY,
hospital_id INT NULL,
full_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
specialty VARCHAR(255),
qualifications TEXT,
specialities TEXT,
contact_phone VARCHAR(255),
license_number VARCHAR(255),
cv_path VARCHAR(255),
license_upload_path VARCHAR(255),
consultation_fee DECIMAL(10, 2),
availability TEXT,
status VARCHAR(50) DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (hospital_id) REFERENCES hospitals(id) ON DELETE SET NULL
)");
// Add hospital_id column if it doesn't exist (for backward compatibility)
$pdo->exec("ALTER TABLE `doctors` ADD COLUMN IF NOT EXISTS `hospital_id` INT NULL AFTER `id`, ADD INDEX (`hospital_id`);");
// File upload handling
$cv_path = null;
if (isset($_FILES['cv']) && $_FILES['cv']['error'] == UPLOAD_ERR_OK) {
$upload_dir = 'uploads/doctors/';
if (!is_dir($upload_dir)) mkdir($upload_dir, 0775, true);
$file_name = uniqid() . '-cv-' . basename($_FILES['cv']['name']);
$cv_path = $upload_dir . $file_name;
if (!move_uploaded_file($_FILES['cv']['tmp_name'], $cv_path)) {
throw new Exception("Failed to upload CV file.");
}
}
$license_upload_path = null;
if (isset($_FILES['licenseUpload']) && $_FILES['licenseUpload']['error'] == UPLOAD_ERR_OK) {
$upload_dir = 'uploads/doctors/';
if (!is_dir($upload_dir)) mkdir($upload_dir, 0775, true);
$file_name = uniqid() . '-license-' . basename($_FILES['licenseUpload']['name']);
$license_upload_path = $upload_dir . $file_name;
if (!move_uploaded_file($_FILES['licenseUpload']['tmp_name'], $license_upload_path)) {
throw new Exception("Failed to upload license file.");
}
}
// Hash password
$password_hash = password_hash($_POST['password'], PASSWORD_DEFAULT);
$hospital_id = !empty($_POST['hospital_id']) ? $_POST['hospital_id'] : null;
// Insert data
$stmt = $pdo->prepare(
"INSERT INTO doctors (hospital_id, full_name, email, password, specialty, license_number, cv_path, license_upload_path, consultation_fee, availability, qualifications, specialities, contact_phone)
VALUES (:hospital_id, :full_name, :email, :password, :specialty, :license_number, :cv_path, :license_upload_path, :consultation_fee, :availability, :qualifications, :specialities, :contact_phone)"
);
$stmt->bindParam(':hospital_id', $hospital_id, PDO::PARAM_INT);
$stmt->bindParam(':full_name', $_POST['fullName']);
$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':password', $password_hash);
$stmt->bindParam(':specialty', $_POST['specialty']);
$stmt->bindParam(':license_number', $_POST['licenseNumber']);
$stmt->bindParam(':cv_path', $cv_path);
$stmt->bindParam(':license_upload_path', $license_upload_path);
$stmt->bindParam(':consultation_fee', $_POST['consultationFee']);
$stmt->bindParam(':availability', $_POST['availability']);
$stmt->bindParam(':qualifications', $_POST['qualifications']);
$stmt->bindParam(':specialities', $_POST['specialities']);
$stmt->bindParam(':contact_phone', $_POST['contact_phone']);
$stmt->execute();
$success_message = "Registration successful! Your profile will be reviewed shortly.";
} catch (PDOException $e) {
if ($e->getCode() == 23000) { // Integrity constraint violation (duplicate entry)
$error_message = "An account with this email address already exists.";
} else {
$error_message = "Database error: " . $e->getMessage();
}
} catch (Exception $e) {
$error_message = "An error occurred: " . $e->getMessage();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Doctor Registration - Medicaltour</title>
<meta name="description" content="Doctor registration for Medicaltour.">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">Medicaltour</a>
<div class="collapse navbar-collapse">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
<li class="nav-item"><a class="nav-link" href="dashboard.php">Dashboard</a></li>
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
</ul>
</div>
</div>
</nav>
</header>
<main class="container mt-5 pt-5">
<div class="row">
<div class="col-md-8 mx-auto">
<h2 class="text-center mb-4">Doctor Registration</h2>
<?php if ($success_message): ?>
<div class="alert alert-success"><?php echo $success_message; ?></div>
<?php endif; ?>
<?php if ($error_message): ?>
<div class="alert alert-danger"><?php echo $error_message; ?></div>
<?php endif; ?>
<?php if (!$success_message): ?>
<p class="text-center mb-4">Join our network of trusted medical professionals.</p>
<form action="doctor-registration.php" method="post" enctype="multipart/form-data">
<div class="row">
<div class="col-md-6 mb-3">
<label for="fullName" class="form-label">Full Name</label>
<input type="text" class="form-control" id="fullName" name="fullName" required>
</div>
<div class="col-md-6 mb-3">
<label for="email" class="form-label">Email Address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="col-md-6 mb-3">
<label for="specialty" class="form-label">Primary Specialty</label>
<input type="text" class="form-control" id="specialty" name="specialty" required>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="contact_phone" class="form-label">Contact Phone</label>
<input type="text" class="form-control" id="contact_phone" name="contact_phone">
</div>
<div class="col-md-6 mb-3">
<label for="licenseNumber" class="form-label">Medical License Number</label>
<input type="text" class="form-control" id="licenseNumber" name="licenseNumber" required>
</div>
</div>
<div class="mb-3">
<label for="qualifications" class="form-label">Qualifications</label>
<textarea class="form-control" id="qualifications" name="qualifications" rows="3" placeholder="e.g., MD, PhD, Board Certified in..."></textarea>
</div>
<div class="mb-3">
<label for="specialities" class="form-label">Additional Specialities</label>
<textarea class="form-control" id="specialities" name="specialities" rows="3" placeholder="e.g., Cardiology, Pediatrics, etc."></textarea>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="cv" class="form-label">CV/Resume Upload</label>
<input class="form-control" type="file" id="cv" name="cv">
</div>
<div class="col-md-6 mb-3">
<label for="licenseUpload" class="form-label">Medical License Upload</label>
<input class="form-control" type="file" id="licenseUpload" name="licenseUpload">
</div>
</div>
<div class="mb-3">
<label for="hospital_id" class="form-label">Affiliated Hospital (Optional)</label>
<select class="form-select" id="hospital_id" name="hospital_id">
<option value="">None</option>
<?php foreach ($hospitals as $hospital): ?>
<option value="<?php echo htmlspecialchars($hospital['id']); ?>">
<?php echo htmlspecialchars($hospital['name']); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="mb-3">
<label for="consultationFee" class="form-label">Consultation Fee (USD)</label>
<input type="number" class="form-control" id="consultationFee" name="consultationFee" min="0" step="1">
</div>
<div class="mb-3">
<label for="availability" class="form-label">Availability Schedule</label>
<textarea class="form-control" id="availability" name="availability" rows="3" placeholder="e.g., Mondays & Wednesdays, 9am - 5pm"></textarea>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary">Register</button>
</div>
</form>
<?php endif; ?>
</div>
</div>
</main>
<footer class="py-4 bg-dark text-white text-center mt-auto">
<div class="container">
<p>&copy; 2025 Medicaltour. All Rights Reserved.</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

149
hospital-doctors.php Normal file
View File

@ -0,0 +1,149 @@
<?php
session_start();
require_once 'db/config.php';
// Ensure user is logged in and is a hospital admin
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'hospital') {
header("Location: login.php");
exit;
}
$hospitalId = $_SESSION['user_id'];
$message = '';
try {
$pdo = db();
// Add hospital_id to doctors table if it doesn't exist
$pdo->exec("ALTER TABLE `doctors` ADD COLUMN IF NOT EXISTS `hospital_id` INT NULL AFTER `id`, ADD INDEX (`hospital_id`);");
// Handle form submission to add a new doctor
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['email'])) {
$fullName = $_POST['full_name'];
$email = $_POST['email'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
if (!empty($email) && !empty($fullName) && !empty($_POST['password'])) {
$stmt = $pdo->prepare("INSERT INTO doctors (hospital_id, full_name, email, password, status) VALUES (:hospital_id, :full_name, :email, :password, 'active')");
$stmt->bindParam(':hospital_id', $hospitalId, PDO::PARAM_INT);
$stmt->bindParam(':full_name', $fullName, PDO::PARAM_STR);
$stmt->bindParam(':email', $email, PDO::PARAM_STR);
$stmt->bindParam(':password', $password, PDO::PARAM_STR);
if ($stmt->execute()) {
$message = '<div class="alert alert-success">Doctor added successfully!</div>';
} else {
$message = '<div class="alert alert-danger">Failed to add doctor. The email might already be registered.</div>';
}
} else {
$message = '<div class="alert alert-warning">Please fill all required fields.</div>';
}
}
// Fetch existing doctors for this hospital
$stmt = $pdo->prepare("SELECT id, full_name, email, specialty FROM doctors WHERE hospital_id = :hospital_id ORDER BY full_name");
$stmt->bindParam(':hospital_id', $hospitalId, PDO::PARAM_INT);
$stmt->execute();
$doctors = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
$message = '<div class="alert alert-danger">Database error: ' . $e->getMessage() . '</div>';
$doctors = [];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manage Doctors - Medicaltour</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">Medicaltour</a>
<div class="collapse navbar-collapse">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="dashboard.php">Dashboard</a></li>
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
</ul>
</div>
</div>
</nav>
<!-- Page Content -->
<main class="container mt-5 pt-5">
<section id="manage-doctors" class="py-5">
<h2 class="mb-4">Manage Doctors</h2>
<?php echo $message; ?>
<!-- Add Doctor Form -->
<div class="card mb-4">
<div class="card-header">Add New Doctor</div>
<div class="card-body">
<form action="hospital-doctors.php" method="POST">
<div class="mb-3">
<label for="full_name" class="form-label">Full Name</label>
<input type="text" class="form-control" id="full_name" name="full_name" required>
</div>
<div class="mb-3">
<label for="email" class="form-label">Email Address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Temporary Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Add Doctor</button>
</form>
</div>
</div>
<!-- Existing Doctors List -->
<div class="card">
<div class="card-header">Your Doctors</div>
<div class="card-body">
<?php if (empty($doctors)): ?>
<p>You have not added any doctors yet.</p>
<?php else: ?>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Specialty</th>
</tr>
</thead>
<tbody>
<?php foreach ($doctors as $doctor): ?>
<tr>
<td><?php echo htmlspecialchars($doctor['full_name']); ?></td>
<td><?php echo htmlspecialchars($doctor['email']); ?></td>
<td><?php echo htmlspecialchars($doctor['specialty'] ?? 'N/A'); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="py-5 bg-dark text-white mt-auto">
<div class="container text-center">
<p>&copy; 2025 Medicaltour. All Rights Reserved.</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

237
hospital-registration.php Normal file
View File

@ -0,0 +1,237 @@
<?php
session_start();
require_once 'db/config.php';
$success_message = '';
$error_message = '';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
try {
$pdo = db();
// Create table if it doesn't exist
$pdo->exec("CREATE TABLE IF NOT EXISTS hospitals (
id INT AUTO_INCREMENT PRIMARY KEY,
hospital_name VARCHAR(255) NOT NULL,
address VARCHAR(255),
contact_person VARCHAR(255),
contact_email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
specialties TEXT,
accreditation_path VARCHAR(255),
billing_details TEXT,
subscription_plan VARCHAR(50),
logo_path VARCHAR(255),
gallery_paths TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)");
// File upload handling
$upload_dir = 'uploads/hospitals/';
$accreditation_path = null;
if (isset($_FILES['accreditation']) && $_FILES['accreditation']['error'] == UPLOAD_ERR_OK) {
$file_name = uniqid() . '-accreditation-' . basename($_FILES['accreditation']['name']);
$accreditation_path = $upload_dir . $file_name;
if (!move_uploaded_file($_FILES['accreditation']['tmp_name'], $accreditation_path)) {
throw new Exception("Failed to upload accreditation file.");
}
}
$logo_path = null;
if (isset($_FILES['logo']) && $_FILES['logo']['error'] == UPLOAD_ERR_OK) {
$file_name = uniqid() . '-logo-' . basename($_FILES['logo']['name']);
$logo_path = $upload_dir . $file_name;
if (!move_uploaded_file($_FILES['logo']['tmp_name'], $logo_path)) {
throw new Exception("Failed to upload logo file.");
}
}
$gallery_paths = [];
if (isset($_FILES['gallery']['name']) && is_array($_FILES['gallery']['name'])) {
foreach ($_FILES['gallery']['tmp_name'] as $key => $tmp_name) {
if ($_FILES['gallery']['error'][$key] == UPLOAD_ERR_OK) {
$file_name = uniqid() . '-gallery-' . basename($_FILES['gallery']['name'][$key]);
$gallery_path = $upload_dir . $file_name;
if (move_uploaded_file($tmp_name, $gallery_path)) {
$gallery_paths[] = $gallery_path;
}
}
}
}
$gallery_paths_json = json_encode($gallery_paths);
// Hash password
$password_hash = password_hash($_POST['password'], PASSWORD_DEFAULT);
// Insert data
$stmt = $pdo->prepare(
"INSERT INTO hospitals (hospital_name, address, contact_person, contact_email, password, specialties, accreditation_path, billing_details, subscription_plan, logo_path, gallery_paths)
VALUES (:hospital_name, :address, :contact_person, :contact_email, :password, :specialties, :accreditation_path, :billing_details, :subscription_plan, :logo_path, :gallery_paths)"
);
$stmt->bindParam(':hospital_name', $_POST['hospitalName']);
$stmt->bindParam(':address', $_POST['address']);
$stmt->bindParam(':contact_person', $_POST['contactPerson']);
$stmt->bindParam(':contact_email', $_POST['contactEmail']);
$stmt->bindParam(':password', $password_hash);
$stmt->bindParam(':specialties', $_POST['specialties']);
$stmt->bindParam(':accreditation_path', $accreditation_path);
$stmt->bindParam(':billing_details', $_POST['billingDetails']);
$stmt->bindParam(':subscription_plan', $_POST['subscriptionPlan']);
$stmt->bindParam(':logo_path', $logo_path);
$stmt->bindParam(':gallery_paths', $gallery_paths_json);
$stmt->execute();
$success_message = "Registration successful! Your hospital profile will be reviewed shortly.";
} catch (PDOException $e) {
if ($e->getCode() == 23000) { // Integrity constraint violation (duplicate entry)
$error_message = "An account with this email address already exists.";
} else {
$error_message = "Database error: " . $e->getMessage();
}
} catch (Exception $e) {
$error_message = "An error occurred: " . $e->getMessage();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hospital Registration - Medicaltour</title>
<meta name="description" content="Hospital registration for Medicaltour.">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<style>
body {
padding-top: 5rem;
}
</style>
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">Medicaltour</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="index.php#hero">Home</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#about">About</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#portfolio">Services</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#testimonials">Testimonials</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#contact">Contact</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Register
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="patient-registration.php">Patient</a></li>
<li><a class="dropdown-item" href="doctor-registration.php">Doctor</a></li>
<li><a class="dropdown-item" href="hospital-registration.php">Hospital</a></li>
</ul>
</li>
<li class="nav-item"><a class="nav-link" href="login.php">Login</a></li>
</ul>
</div>
</div>
</nav>
</header>
<main class="container my-5">
<div class="row">
<div class="col-md-8 mx-auto">
<h2 class="text-center mb-4">Hospital Registration</h2>
<?php if ($success_message): ?>
<div class="alert alert-success"><?php echo $success_message; ?></div>
<?php endif; ?>
<?php if ($error_message): ?>
<div class="alert alert-danger"><?php echo $error_message; ?></div>
<?php endif; ?>
<?php if (!$success_message): ?>
<p class="text-center mb-4">Register your hospital to be part of our exclusive network.</p>
<form action="hospital-registration.php" method="post" enctype="multipart/form-data">
<div class="mb-3">
<label for="hospitalName" class="form-label">Hospital Name</label>
<input type="text" class="form-control" id="hospitalName" name="hospitalName" required>
</div>
<div class="mb-3">
<label for="address" class="form-label">Address</label>
<input type="text" class="form-control" id="address" name="address" required>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="contactPerson" class="form-label">Contact Person</label>
<input type="text" class="form-control" id="contactPerson" name="contactPerson" required>
</div>
<div class="col-md-6 mb-3">
<label for="contactEmail" class="form-label">Contact Email</label>
<input type="email" class="form-control" id="contactEmail" name="contactEmail" required>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="col-md-6 mb-3">
<label for="specialties" class="form-label">Specialties</label>
<input type="text" class="form-control" id="specialties" name="specialties" placeholder="e.g., Cardiology, Neurology">
</div>
</div>
<div class="mb-3">
<label for="accreditation" class="form-label">Accreditation/License Upload</label>
<input class="form-control" type="file" id="accreditation" name="accreditation">
</div>
<div class="mb-3">
<label for="billingDetails" class="form-label">Bank/Billing Details</label>
<textarea class="form-control" id="billingDetails" name="billingDetails" rows="3"></textarea>
</div>
<div class="mb-3">
<label for="subscriptionPlan" class="form-label">Subscription Plan</label>
<select class="form-select" id="subscriptionPlan" name="subscriptionPlan">
<option selected>Choose a plan...</option>
<option value="basic">Basic</option>
<option value="premium">Premium</option>
<option value="enterprise">Enterprise</option>
</select>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="logo" class="form-label">Logo Upload</label>
<input class="form-control" type="file" id="logo" name="logo">
</div>
<div class="col-md-6 mb-3">
<label for="gallery" class="form-label">Image Gallery</label>
<input class="form-control" type="file" id="gallery" name="gallery[]" multiple>
</div>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary">Register Hospital</button>
</div>
</form>
<?php endif; ?>
</div>
</div>
</main>
<footer class="py-4 bg-dark text-white text-center">
<div class="container">
<p>&copy; 2025 Medicaltour. All Rights Reserved.</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>

138
hospital-treatments.php Normal file
View File

@ -0,0 +1,138 @@
<?php
session_start();
require_once 'db/config.php';
// Ensure user is logged in and is a hospital admin
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'hospital') {
header("Location: login.php");
exit;
}
$hospitalId = $_SESSION['user_id'];
$message = '';
try {
$pdo = db();
// Create table if it doesn't exist
$pdo->exec("CREATE TABLE IF NOT EXISTS `treatment_categories` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`hospital_id` INT NOT NULL,
`name` VARCHAR(255) NOT NULL,
`description` TEXT,
FOREIGN KEY (`hospital_id`) REFERENCES `hospitals`(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;");
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['category_name'])) {
$categoryName = trim($_POST['category_name']);
$description = trim($_POST['description']);
if (!empty($categoryName)) {
$stmt = $pdo->prepare("INSERT INTO treatment_categories (hospital_id, name, description) VALUES (:hospital_id, :name, :description)");
$stmt->bindParam(':hospital_id', $hospitalId, PDO::PARAM_INT);
$stmt->bindParam(':name', $categoryName, PDO::PARAM_STR);
$stmt->bindParam(':description', $description, PDO::PARAM_STR);
if ($stmt->execute()) {
$message = '<div class="alert alert-success">Treatment category added successfully!</div>';
} else {
$message = '<div class="alert alert-danger">Failed to add category.</div>';
}
} else {
$message = '<div class="alert alert-warning">Category name is required.</div>';
}
}
// Fetch existing categories for this hospital
$stmt = $pdo->prepare("SELECT * FROM treatment_categories WHERE hospital_id = :hospital_id ORDER BY name");
$stmt->bindParam(':hospital_id', $hospitalId, PDO::PARAM_INT);
$stmt->execute();
$categories = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
$message = '<div class="alert alert-danger">Database error: ' . $e->getMessage() . '</div>';
$categories = [];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manage Treatment Categories - Medicaltour</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">Medicaltour</a>
<div class="collapse navbar-collapse">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="dashboard.php">Dashboard</a></li>
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
</ul>
</div>
</div>
</nav>
<!-- Page Content -->
<main class="container mt-5 pt-5">
<section id="manage-treatments" class="py-5">
<h2 class="mb-4">Manage Treatment Categories</h2>
<?php echo $message; ?>
<!-- Add Category Form -->
<div class="card mb-4">
<div class="card-header">Add New Category</div>
<div class="card-body">
<form action="hospital-treatments.php" method="POST">
<div class="mb-3">
<label for="category_name" class="form-label">Category Name</label>
<input type="text" class="form-control" id="category_name" name="category_name" required>
</div>
<div class="mb-3">
<label for="description" class="form-label">Description (Optional)</label>
<textarea class="form-control" id="description" name="description" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-primary">Add Category</button>
</form>
</div>
</div>
<!-- Existing Categories List -->
<div class="card">
<div class="card-header">Your Treatment Categories</div>
<div class="card-body">
<?php if (empty($categories)): ?>
<p>You have not added any treatment categories yet.</p>
<?php else: ?>
<ul class="list-group">
<?php foreach ($categories as $category): ?>
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>
<h6 class="my-0"><?php echo htmlspecialchars($category['name']); ?></h6>
<small class="text-muted"><?php echo htmlspecialchars($category['description']); ?></small>
</div>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="py-5 bg-dark text-white mt-auto">
<div class="container text-center">
<p>&copy; 2025 Medicaltour. All Rights Reserved.</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

486
index.php
View File

@ -1,150 +1,354 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?>
<!doctype html>
<?php session_start(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<?php
// Read project preview data from environment
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<?php if ($projectDescription): ?>
<!-- Meta description -->
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags -->
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Twitter meta tags -->
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}
.loader {
margin: 1.25rem auto 1.25rem;
width: 48px;
height: 48px;
border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hint {
opacity: 0.9;
}
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap; border: 0;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Medicaltour</title>
<meta name="description" content="Built with Flatlogic Generator">
<meta name="keywords" content="medical tourism, hospitals, doctors, travel agents, patient care, international healthcare, medical travel, treatment abroad, healthcare marketplace, Built with Flatlogic Generator">
<meta property="og:title" content="Medicaltour">
<meta property="og:description" content="Built with Flatlogic Generator">
<meta property="og:image" content="">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<main>
<header>
<nav class="navbar navbar-expand-lg fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">Medicaltour</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="index.php#hero">Home</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#about">About</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#portfolio">Services</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#packages">Packages</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#destinations">Destinations</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#testimonials">Testimonials</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#contact">Contact</a></li>
<?php if (isset($_SESSION['user_id'])): ?>
<li class="nav-item"><a class="nav-link" href="dashboard.php">Dashboard</a></li>
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
<?php else: ?>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Register
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="patient-registration.php">Patient</a></li>
<li><a class="dropdown-item" href="doctor-registration.php">Doctor</a></li>
<li><a class="dropdown-item" href="hospital-registration.php">Hospital</a></li>
</ul>
</li>
<li class="nav-item"><a class="nav-link" href="login.php">Login</a></li>
<?php endif; ?>
</ul>
</div>
</div>
</nav>
</header>
<main>
<section id="hero" class="hero text-center">
<div class="container">
<h1 class="display-4">Find Your Trusted Medical Partner Abroad</h1>
<p class="lead">Your one-stop platform for medical tourism. Connect with the best hospitals and doctors worldwide.</p>
<a href="#portfolio" class="btn btn-accent btn-lg mt-3">Explore Services</a>
</div>
</section>
<section id="about" class="section">
<div class="container">
<div class="row align-items-center">
<div class="col-md-6">
<h2>About Us</h2>
<p>We are dedicated to connecting patients with world-class medical facilities and renowned doctors. Our platform simplifies the process of finding and booking medical treatments abroad, ensuring a seamless and stress-free experience.</p>
</div>
<div class="col-md-6 text-center">
<i class="bi bi-heart-pulse-fill" style="font-size: 8rem; color: #0D6EFD;"></i>
</div>
</div>
</div>
</section>
<section id="portfolio" class="section bg-light">
<div class="container">
<h2 class="text-center mb-5">Our Services</h2>
<div class="row">
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body text-center">
<i class="bi bi-hospital" style="font-size: 3rem; color: #198754;"></i>
<h5 class="card-title mt-3">Hospital Listings</h5>
<p class="card-text">Search and compare top-rated hospitals from around the globe.</p>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body text-center">
<i class="bi bi-person-badge" style="font-size: 3rem; color: #198754;"></i>
<h5 class="card-title mt-3">Doctor Profiles</h5>
<p class="card-text">Find experienced specialists and book consultations with ease.</p>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body text-center">
<i class="bi bi-airplane" style="font-size: 3rem; color: #198754;"></i>
<h5 class="card-title mt-3">Travel Packages</h5>
<p class="card-text">Coordinate your travel and accommodation seamlessly with our partners.</p>
</div>
</div>
</div>
</div>
<h3 class="text-center my-5">Major Treatment Categories</h3>
<div class="row">
<div class="col-md-4 col-lg-2 mb-4">
<div class="card h-100 text-center">
<div class="card-body">
<i class="bi bi-heart-pulse" style="font-size: 2rem; color: #0D6EFD;"></i>
<h6 class="card-title mt-2">Cardiology</h6>
</div>
</div>
</div>
<div class="col-md-4 col-lg-2 mb-4">
<div class="card h-100 text-center">
<div class="card-body">
<i class="bi bi-bandaid" style="font-size: 2rem; color: #0D6EFD;"></i>
<h6 class="card-title mt-2">Oncology</h6>
</div>
</div>
</div>
<div class="col-md-4 col-lg-2 mb-4">
<div class="card h-100 text-center">
<div class="card-body">
<i class="bi bi-bone" style="font-size: 2rem; color: #0D6EFD;"></i>
<h6 class="card-title mt-2">Orthopedics</h6>
</div>
</div>
</div>
<div class="col-md-4 col-lg-2 mb-4">
<div class="card h-100 text-center">
<div class="card-body">
<i class="bi bi-brain" style="font-size: 2rem; color: #0D6EFD;"></i>
<h6 class="card-title mt-2">Neurology</h6>
</div>
</div>
</div>
<div class="col-md-4 col-lg-2 mb-4">
<div class="card h-100 text-center">
<div class="card-body">
<i class="bi bi-droplet" style="font-size: 2rem; color: #0D6EFD;"></i>
<h6 class="card-title mt-2">Cosmetic Surgery</h6>
</div>
</div>
</div>
<div class="col-md-4 col-lg-2 mb-4">
<div class="card h-100 text-center">
<div class="card-body">
<i class="bi bi-person-hearts" style="font-size: 2rem; color: #0D6EFD;"></i>
<h6 class="card-title mt-2">Fertility</h6>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="packages" class="section">
<div class="container">
<h2 class="text-center mb-5">Treatment Packages</h2>
<div class="row">
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body d-flex flex-column">
<h5 class="card-title">Cardiac Care Package</h5>
<p class="card-text">Includes initial consultation, coronary angiography, and a 5-day hospital stay in a private room.</p>
<ul class="list-unstyled mt-3 mb-4">
<li><i class="bi bi-check-circle-fill text-success"></i> Full Cardiac Checkup</li>
<li><i class="bi bi-check-circle-fill text-success"></i> 7-Day Luxury Stay</li>
<li><i class="bi bi-check-circle-fill text-success"></i> Airport Transfers</li>
</ul>
<div class="mt-auto text-center">
<p class="h3">$8,500</p>
<button class="btn btn-primary">Book Now</button>
</div>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body d-flex flex-column">
<h5 class="card-title">Orthopedic Wellness</h5>
<p class="card-text">Knee replacement surgery, including pre-op assessments, the procedure, and a 10-day rehabilitation stay.</p>
<ul class="list-unstyled mt-3 mb-4">
<li><i class="bi bi-check-circle-fill text-success"></i> Joint Replacement</li>
<li><i class="bi bi-check-circle-fill text-success"></i> 14-Day Rehab Stay</li>
<li><i class="bi bi-check-circle-fill text-success"></i> Chauffeur Service</li>
</ul>
<div class="mt-auto text-center">
<p class="h3">$12,300</p>
<button class="btn btn-primary">Book Now</button>
</div>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body d-flex flex-column">
<h5 class="card-title">Cosmetic Rejuvenation</h5>
<p class="card-text">A complete package including a facelift, accommodation in a 5-star hotel, and all local transportation.</p>
<ul class="list-unstyled mt-3 mb-4">
<li><i class="bi bi-check-circle-fill text-success"></i> Full Facelift Procedure</li>
<li><i class="bi bi-check-circle-fill text-success"></i> 10-Day Luxury Suite</li>
<li><i class="bi bi-check-circle-fill text-success"></i> Private Tours</li>
</ul>
<div class="mt-auto text-center">
<p class="h3">$15,000</p>
<button class="btn btn-primary">Book Now</button>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="destinations" class="section bg-light">
<div class="container">
<h2 class="text-center mb-5">Top Healthcare Destinations</h2>
<div class="row">
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title"><i class="bi bi-geo-alt-fill text-primary"></i> India</h5>
<ul class="list-unstyled mt-3">
<li><i class="bi bi-pin-map"></i> New Delhi</li>
<li><i class="bi bi-pin-map"></i> Mumbai</li>
<li><i class="bi bi-pin-map"></i> Chennai</li>
<li><i class="bi bi-pin-map"></i> Bangalore</li>
</ul>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title"><i class="bi bi-geo-alt-fill text-primary"></i> Singapore</h5>
<ul class="list-unstyled mt-3">
<li><i class="bi bi-pin-map"></i> Singapore</li>
</ul>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title"><i class="bi bi-geo-alt-fill text-primary"></i> Thailand</h5>
<ul class="list-unstyled mt-3">
<li><i class="bi bi-pin-map"></i> Bangkok</li>
<li><i class="bi bi-pin-map"></i> Phuket</li>
</ul>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title"><i class="bi bi-geo-alt-fill text-primary"></i> Malaysia</h5>
<ul class="list-unstyled mt-3">
<li><i class="bi bi-pin-map"></i> Kuala Lumpur</li>
<li><i class="bi bi-pin-map"></i> Penang</li>
</ul>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title"><i class="bi bi-geo-alt-fill text-primary"></i> Turkey</h5>
<ul class="list-unstyled mt-3">
<li><i class="bi bi-pin-map"></i> Istanbul</li>
<li><i class="bi bi-pin-map"></i> Ankara</li>
</ul>
</div>
</div>
</div>
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title"><i class="bi bi-geo-alt-fill text-primary"></i> Mexico</h5>
<ul class="list-unstyled mt-3">
<li><i class="bi bi-pin-map"></i> Tijuana</li>
<li><i class="bi bi-pin-map"></i> Cancun</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="testimonials" class="section">
<div class="container">
<h2 class="text-center mb-5">What Our Patients Say</h2>
<div class="row">
<div class="col-md-6 mx-auto">
<div class="card">
<h1>Analyzing your requirements and generating your website…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
<div class="card-body">
<p class="fst-italic">"The platform made it so easy to find a great hospital for my procedure. The entire process was smooth and well-organized. Highly recommended!"</p>
<footer class="blockquote-footer text-end">John Doe</footer>
</div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will update automatically as the plan is implemented.</p>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
</div>
</div>
</div>
</section>
<section id="contact" class="section bg-light">
<div class="container">
<h2 class="text-center mb-5">Contact Us</h2>
<div class="row">
<div class="col-md-8 mx-auto">
<form>
<div class="mb-3">
<input type="text" class="form-control" placeholder="Your Name">
</div>
<div class="mb-3">
<input type="email" class="form-control" placeholder="Your Email">
</div>
<div class="mb-3">
<textarea class="form-control" rows="5" placeholder="Your Message"></textarea>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary">Send Message</button>
</div>
</form>
</div>
</div>
</div>
</section>
</main>
<footer class="py-4 bg-dark text-white text-center">
<div class="container">
<p>&copy; 2025 Medicaltour. All Rights Reserved.</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>

144
login.php Normal file
View File

@ -0,0 +1,144 @@
<?php
session_start();
require_once 'db/config.php';
$message = '';
if (isset($_SESSION['user_id'])) {
header("Location: dashboard.php");
exit;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$email = $_POST['email'];
$password = $_POST['password'];
$role = null;
$user_id = null;
$user_name = null;
try {
$pdo = db();
// 1. Check admins table
$stmt = $pdo->prepare("SELECT id, name, password, role FROM admins WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$role = $user['role'];
$user_id = $user['id'];
$user_name = $user['name'];
}
// 2. Check patients table (if not found in admins)
if (!$user_id) {
$stmt = $pdo->prepare("SELECT id, full_name as name, password FROM patients WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$role = 'patient';
$user_id = $user['id'];
$user_name = $user['name'];
}
}
// 3. Check doctors table (if not found yet)
if (!$user_id) {
$stmt = $pdo->prepare("SELECT id, full_name as name, password FROM doctors WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$role = 'doctor';
$user_id = $user['id'];
$user_name = $user['name'];
}
}
// 4. Check hospitals table (if not found yet)
if (!$user_id) {
$stmt = $pdo->prepare("SELECT id, hospital_name as name, password FROM hospitals WHERE contact_email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$role = 'hospital';
$user_id = $user['id'];
$user_name = $user['name'];
}
}
if ($user_id) {
$_SESSION['user_id'] = $user_id;
$_SESSION['user_name'] = $user_name;
$_SESSION['user_role'] = $role;
$_SESSION['user_email'] = $email;
header("Location: dashboard.php");
exit;
} else {
$message = '<div class="alert alert-danger">Invalid email or password.</div>';
}
} catch (PDOException $e) {
$message = '<div class="alert alert-danger">Database error: ' . $e->getMessage() . '</div>';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Medicaltour</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">Medicaltour</a>
</div>
</nav>
<!-- Page Content -->
<main class="container mt-5 pt-5">
<section id="login" class="py-5">
<div class="row justify-content-center">
<div class="col-md-5">
<h2 class="mb-4 text-center">Login</h2>
<p class="text-center text-muted">Access your dashboard.</p>
<?php if (!empty($message)) echo $message; ?>
<form action="login.php" method="post">
<div class="mb-3">
<label for="email" class="form-label">Email Address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</form>
<div class="text-center mt-3">
<p>Don't have an account? <a href="index.php#register">Register here</a></p>
</div>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="py-5 bg-dark text-white mt-auto">
<div class="container text-center">
<p>&copy; 2025 Medicaltour. All Rights Reserved.</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>

7
logout.php Normal file
View File

@ -0,0 +1,7 @@
<?php
session_start();
session_unset();
session_destroy();
header("Location: login.php");
exit;
?>

196
patient-registration.php Normal file
View File

@ -0,0 +1,196 @@
<?php
session_start();
require_once 'db/config.php';
$success_message = '';
$error_message = '';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
try {
$pdo = db();
// Create table if it doesn't exist
$pdo->exec("CREATE TABLE IF NOT EXISTS patients (
id INT AUTO_INCREMENT PRIMARY KEY,
full_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
dob DATE,
passport_id_path VARCHAR(255),
contact_number VARCHAR(50),
emergency_contact VARCHAR(50),
medical_history TEXT,
insurance_info VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)");
// File upload handling
$passport_id_path = null;
if (isset($_FILES['passportId']) && $_FILES['passportId']['error'] == UPLOAD_ERR_OK) {
$upload_dir = 'uploads/passports/';
$file_name = uniqid() . '-' . basename($_FILES['passportId']['name']);
$passport_id_path = $upload_dir . $file_name;
if (!move_uploaded_file($_FILES['passportId']['tmp_name'], $passport_id_path)) {
throw new Exception("Failed to upload passport/ID file.");
}
}
// Hash password
$password_hash = password_hash($_POST['password'], PASSWORD_DEFAULT);
// Insert data
$stmt = $pdo->prepare(
"INSERT INTO patients (full_name, email, password, dob, passport_id_path, contact_number, emergency_contact, medical_history, insurance_info)
VALUES (:full_name, :email, :password, :dob, :passport_id_path, :contact_number, :emergency_contact, :medical_history, :insurance_info)"
);
$stmt->bindParam(':full_name', $_POST['fullName']);
$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':password', $password_hash);
$stmt->bindParam(':dob', $_POST['dob']);
$stmt->bindParam(':passport_id_path', $passport_id_path);
$stmt->bindParam(':contact_number', $_POST['contactNumber']);
$stmt->bindParam(':emergency_contact', $_POST['emergencyContact']);
$stmt->bindParam(':medical_history', $_POST['medicalHistory']);
$stmt->bindParam(':insurance_info', $_POST['insuranceInfo']);
$stmt->execute();
$success_message = "Registration successful! You can now log in.";
} catch (PDOException $e) {
if ($e->getCode() == 23000) { // Integrity constraint violation (duplicate entry)
$error_message = "An account with this email address already exists.";
} else {
$error_message = "Database error: " . $e->getMessage();
}
} catch (Exception $e) {
$error_message = "An error occurred: " . $e->getMessage();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Patient Registration - Medicaltour</title>
<meta name="description" content="Patient registration for Medicaltour.">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<style>
body {
padding-top: 5rem;
}
</style>
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg fixed-top">
<div class="container">
<a class="navbar-brand" href="index.php">Medicaltour</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="index.php#hero">Home</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#about">About</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#portfolio">Services</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#testimonials">Testimonials</a></li>
<li class="nav-item"><a class="nav-link" href="index.php#contact">Contact</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Register
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="patient-registration.php">Patient</a></li>
<li><a class="dropdown-item" href="doctor-registration.php">Doctor</a></li>
<li><a class="dropdown-item" href="hospital-registration.php">Hospital</a></li>
</ul>
</li>
<li class="nav-item"><a class="nav-link" href="login.php">Login</a></li>
</ul>
</div>
</div>
</nav>
</header>
<main class="container my-5">
<div class="row">
<div class="col-md-8 mx-auto">
<h2 class="text-center mb-4">Patient Registration</h2>
<?php if ($success_message): ?>
<div class="alert alert-success"><?php echo $success_message; ?></div>
<?php endif; ?>
<?php if ($error_message): ?>
<div class="alert alert-danger"><?php echo $error_message; ?></div>
<?php endif; ?>
<?php if (!$success_message): ?>
<p class="text-center mb-4">Create your account to access our services.</p>
<form action="patient-registration.php" method="post" enctype="multipart/form-data">
<div class="row">
<div class="col-md-6 mb-3">
<label for="fullName" class="form-label">Full Name</label>
<input type="text" class="form-control" id="fullName" name="fullName" required>
</div>
<div class="col-md-6 mb-3">
<label for="email" class="form-label">Email Address</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="col-md-6 mb-3">
<label for="dob" class="form-label">Date of Birth</label>
<input type="date" class="form-control" id="dob" name="dob" required>
</div>
</div>
<div class="mb-3">
<label for="passportId" class="form-label">Passport / ID Upload</label>
<input class="form-control" type="file" id="passportId" name="passportId">
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="contactNumber" class="form-label">Contact Number</label>
<input type="tel" class="form-control" id="contactNumber" name="contactNumber">
</div>
<div class="col-md-6 mb-3">
<label for="emergencyContact" class="form-label">Emergency Contact Number</label>
<input type="tel" class="form-control" id="emergencyContact" name="emergencyContact">
</div>
</div>
<div class="mb-3">
<label for="medicalHistory" class="form-label">Basic Medical History</label>
<textarea class="form-control" id="medicalHistory" name="medicalHistory" rows="3"></textarea>
</div>
<div class="mb-3">
<label for="insuranceInfo" class="form-label">Insurance Information</label>
<input type="text" class="form-control" id="insuranceInfo" name="insuranceInfo">
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary">Register</button>
</div>
</form>
<?php endif; ?>
</div>
</div>
</main>
<footer class="py-4 bg-dark text-white text-center">
<div class="container">
<p>&copy; 2025 Medicaltour. All Rights Reserved.</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>