|
| 1 | +<?php |
| 2 | +require_once('../connection.php'); |
| 3 | +session_start(); |
| 4 | + |
| 5 | +try { |
| 6 | + $conn = Teledoc::connect(); |
| 7 | + |
| 8 | + // Fetch user details |
| 9 | + $query = "SELECT * FROM info WHERE user_type = 0 AND id = :user_id"; |
| 10 | + $stmt = $conn->prepare($query); |
| 11 | + $stmt->bindParam(':user_id', $_SESSION['user_id']); |
| 12 | + $stmt->execute(); |
| 13 | + $user = $stmt->fetch(PDO::FETCH_ASSOC); |
| 14 | + |
| 15 | + if ($_SERVER["REQUEST_METHOD"] == "POST") { |
| 16 | + $name = $_POST['name']; |
| 17 | + $email = $_POST['email']; |
| 18 | + $degree = $_POST['degree']; |
| 19 | + $speciality = $_POST['speciality']; |
| 20 | + $division = $_POST['division']; |
| 21 | + $chamber_number = $_POST['chamber_number']; |
| 22 | + $hospital = $_POST['hospital']; |
| 23 | + $chamber_location = $_POST['chamber_location']; |
| 24 | + $time_start = $_POST['time_start']; |
| 25 | + $time_end = $_POST['time_end']; |
| 26 | + $password = $_POST['password']; |
| 27 | + $visitcharge = $_POST['visitcharge']; |
| 28 | + |
| 29 | + // Prepare SQL statement |
| 30 | + |
| 31 | + // INSERT INTO `doctor` (`IndexNumber`, ``, , `Password`, , ``, ``, ``, `TimeStart`, `TimeEnd`, `VisitCharge`) VALUES |
| 32 | + |
| 33 | + $query = "INSERT INTO doctor |
| 34 | + (Name, Email, Degree, Speciality, Division, ChamberNumber, Hospital, ChamberLocation, TimeStart, TimeEnd, password,VisitCharge) |
| 35 | + VALUES |
| 36 | + (:name, :email, :degree, :speciality, :division, :chamber_number, :hospital, :chamber_location, :time_start, :time_end, :password,:visitcharge)"; |
| 37 | + |
| 38 | + $stmt = $conn->prepare($query); |
| 39 | + |
| 40 | + // Bind parameters |
| 41 | + $stmt->bindParam(':name', $name); |
| 42 | + $stmt->bindParam(':email', $email); |
| 43 | + $stmt->bindParam(':degree', $degree); |
| 44 | + $stmt->bindParam(':speciality', $speciality); |
| 45 | + $stmt->bindParam(':division', $division); |
| 46 | + $stmt->bindParam(':chamber_number', $chamber_number); |
| 47 | + $stmt->bindParam(':hospital', $hospital); |
| 48 | + $stmt->bindParam(':chamber_location', $chamber_location); |
| 49 | + $stmt->bindParam(':time_start', $time_start); |
| 50 | + $stmt->bindParam(':time_end', $time_end); |
| 51 | + $stmt->bindParam(':password', $password); |
| 52 | + $stmt->bindParam(':visitcharge', $visitcharge); |
| 53 | + |
| 54 | + // Execute the query |
| 55 | + try { |
| 56 | + $stmt->execute(); |
| 57 | + echo '<script>alert("New Doctor Added inserted successfully!"); </script>'; |
| 58 | + |
| 59 | + } catch(PDOException $e) { |
| 60 | + echo "Error: " . $e->getMessage(); |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +} catch(PDOException $e) { |
| 65 | + echo 'Error: ' . $e->getMessage(); |
| 66 | +} |
| 67 | + |
| 68 | +require('header.php'); |
| 69 | +?> |
| 70 | + |
| 71 | +<div class="container"> |
| 72 | + <div class="row justify-content-center"> |
| 73 | + <div class="col-md-8"> |
| 74 | + <div class="card"> |
| 75 | + <div class="card-header text-center"> |
| 76 | + <h3>Admin | Add Doctor</h3> |
| 77 | + </div> |
| 78 | + <div class="card-body"> |
| 79 | + <div class="form-group d-flex flex-column"> |
| 80 | + <label for="username" class="font-weight-bold">Username:</label> |
| 81 | + <input type="text" readonly class="form-control" id="username" value="<?php echo $user['name']; ?>"> |
| 82 | + </div> |
| 83 | + <div class="form-group d-flex flex-column"> |
| 84 | + <label for="total_doctors" class="font-weight-bold">Total Registered Doctor</label> |
| 85 | + <input type="text" readonly class="form-control" id="total_doctors" value="<?php echo $docnumber; ?>"> |
| 86 | + </div> |
| 87 | + <div class="table-responsive mt-4"> |
| 88 | + <!-- Form for adding new doctor --> |
| 89 | + <form action="" method="post" id="addDoctorForm"> |
| 90 | + <div class="form-group"> |
| 91 | + <label for="name">Name:</label> |
| 92 | + <input type="text" class="form-control" id="name" name="name" placeholder="Enter Name" required> |
| 93 | + </div> |
| 94 | + <div class="form-group"> |
| 95 | + <label for="email">Email:</label> |
| 96 | + <input type="email" class="form-control" id="email" name="email" placeholder="Enter Email" required> |
| 97 | + </div> |
| 98 | + <div class="form-group"> |
| 99 | + <label for="degree">Degree:</label> |
| 100 | + <input type="text" class="form-control" id="degree" name="degree" placeholder="Enter Degree" required> |
| 101 | + </div> |
| 102 | + <div class="form-group"> |
| 103 | + <label for="speciality">Speciality:</label> |
| 104 | + <input type="text" class="form-control" id="speciality" name="speciality" placeholder="Enter Speciality" required> |
| 105 | + </div> |
| 106 | + <div class="form-group"> |
| 107 | + <label for="division">Division:</label> |
| 108 | + <select class="form-control" id="division" name="division" required> |
| 109 | + <option value="Sylhet">Sylhet</option> |
| 110 | + <option value="Barishal">Barishal</option> |
| 111 | + <option value="Chittagong">Chittagong</option> |
| 112 | + <option value="Dhaka">Dhaka</option> |
| 113 | + <option value="Khulna">Khulna</option> |
| 114 | + <option value="Rajshahi">Rajshahi</option> |
| 115 | + <option value="Rangpur">Rangpur</option> |
| 116 | + <option value="Mymensingh">Mymensingh</option> |
| 117 | + </select> |
| 118 | + </div> |
| 119 | + <div class="form-group"> |
| 120 | + <label for="chamber_number">Chamber Number:</label> |
| 121 | + <input type="text" class="form-control" id="chamber_number" name="chamber_number" placeholder="Enter Chamber Number" required> |
| 122 | + </div> |
| 123 | + <div class="form-group"> |
| 124 | + <label for="hospital">Hospital Name:</label> |
| 125 | + <input type="text" class="form-control" id="hospital" name="hospital" placeholder="Enter Hospital" required> |
| 126 | + </div> |
| 127 | + <div class="form-group"> |
| 128 | + <label for="chamber_location">Chamber Location:</label> |
| 129 | + <input type="text" class="form-control" id="chamber_location" name="chamber_location" placeholder="Enter Chamber Location" required> |
| 130 | + </div> |
| 131 | + <div class="form-group"> |
| 132 | + <label for="time_start">Time Start:</label> |
| 133 | + <input type="time" class="form-control" id="time_start" name="time_start" required> |
| 134 | + </div> |
| 135 | + <div class="form-group"> |
| 136 | + <label for="time_end">Time End:</label> |
| 137 | + <input type="time" class="form-control" id="time_end" name="time_end" required> |
| 138 | + </div> |
| 139 | + |
| 140 | + <div class="form-group"> |
| 141 | + <label for="visitcharge">Visit Charge:</label> |
| 142 | + <input type="number" class="form-control" id="visitcharge" name="visitcharge" placeholder="Enter Visit Charge" required> |
| 143 | + </div> |
| 144 | + <div class="form-group"> |
| 145 | + <label for="password">Password:</label> |
| 146 | + <input type="password" class="form-control" id="password" name="password" placeholder="Enter Password" required> |
| 147 | + </div> |
| 148 | + <div class="form-group"> |
| 149 | + <label for="confirm_password">Confirm Password:</label> |
| 150 | + <input type="password" class="form-control" id="confirm_password" name="confirm_password" placeholder="Enter Confirmed Password" required> |
| 151 | + <small id="passwordHelpBlock" class="form-text text-danger"></small> |
| 152 | + </div> |
| 153 | + <button type="submit" class="btn btn-primary">Submit</button> |
| 154 | + </form> |
| 155 | + </div> |
| 156 | + </div> |
| 157 | + <div class="card-footer text-center"> |
| 158 | + <a href="admin_logout.php" class="btn btn-danger">Logout</a> |
| 159 | + </div> |
| 160 | + </div> |
| 161 | + </div> |
| 162 | + </div> |
| 163 | +</div> |
| 164 | + |
| 165 | +<script> |
| 166 | + document.addEventListener('DOMContentLoaded', function() { |
| 167 | + document.getElementById('addDoctorForm').addEventListener('submit', function(event) { |
| 168 | + let password = document.getElementById('password').value; |
| 169 | + let confirmPassword = document.getElementById('confirm_password').value; |
| 170 | + let error = document.getElementById('passwordHelpBlock'); |
| 171 | + |
| 172 | + if (password !== confirmPassword) { |
| 173 | + error.textContent = "Passwords do not match!"; |
| 174 | + event.preventDefault(); // Prevent form submission |
| 175 | + } else { |
| 176 | + error.textContent = ""; // Clear error message if passwords match |
| 177 | + } |
| 178 | + }); |
| 179 | + }); |
| 180 | +</script> |
| 181 | + |
| 182 | + |
| 183 | +<?php require("footer.php"); ?> |
0 commit comments