Code of Marriage Beuro Management System Project in PHP
Marriage Beuro Management System is web-based online application software that gives us an automated and online platform for registering marriage records for new couples. Marriage Beuro Management System allows users to submit marriage information and the management will verify it for new couples.
This application project is developed using the following languages, tools, and technologies;
- HTML
- CSS
- JavaScript
- PHP Language
- MySQL Database
- Bootstrap
- jQuery
- XAMPP
- Ajax
The Marriage Beuro Management System has mainly three  types of users ;
- Administrator
- Staff
- User
The user can register their account to access the Marriage Beuro Management System functionalities that are restricted according to the mentioned user role. The user can create a new application for their marriage contract for new couples. Then, Â the new couples can update, view, list, delete, and can show their created applications.
Functional Requirements of Marriage Beuro Management System Project in PHP
Admin Functional Requirements
- Admin can log in or Logout
- Admin can view the Dashboard
- Admin can Manage Client List
- Admin can Create New list
- Admin can  view, delete, update and search a List
- Admin can View or print Details
- Admin can Update Details
- Admin can Delete Data
- Admin can Manage Applications
- Admin can view, insert, delete, update and search List Applications
- Admin can View Application Details
- Admin can Update Application
- Admin can Print Marriage Certificate
- Admin can Delete Data
- Admin can Manage User List (Admin/Staff)
- Admin can Manage Marriage Beuro Management System Information
- Admin can Update Account Information of the registered users.
User-Side Functional Requirements
- Couples can log in and Registration
- Couples can view Dashboard
- Couples can Submit Application
- Couples can Edit Application Details
- Couples can View Application Details
- Couples can Delete Application
- Couples can Update Account Information/Credentials
- Couples can Logout
Master.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
<?php require_once('../config.php'); Class Master extends DBConnection { private $settings; public function __construct(){ global $_settings; $this->settings = $_settings; parent::__construct(); } public function __destruct(){ parent::__destruct(); } function capture_err(){ if(!$this->conn->error) return false; else{ $resp['status'] = 'failed'; $resp['error'] = $this->conn->error; return json_encode($resp); exit; } } function save_marriage_information(){ if(empty($_POST['id'])){ $prefix = implode('',range('A','Z')); $prefix = substr(str_shuffle($prefix),0,3)."-"; $i = sprintf("%'.04d",1); while(true){ $code = $prefix.$i; $check = $this->conn->query("SELECT id FROM `registration_list` where registration_code = '{$code}'")->num_rows; if($check <= 0){ break; }else{ $i = sprintf("%'.04d",abs($i)+1); } } $_POST['registration_code'] = $code; $_POST['client_id'] = $this->settings->userdata('id'); } if(isset($_POST['status'])){ $get = $this->conn->query("SELECT * FROM `registration_list` where id= '{$_POST['id']}'"); if($get->num_rows > 0){ $res = $get->fetch_array(); if($_POST['status'] != $res['status']){ $_POST['action_user_id'] = $this->settings->userdata('id'); } } } extract($_POST); $data = ""; foreach($_POST as $k =>$v){ if(in_array($k,array('registration_code','client_id','schedule','action_user_id','status'))){ if(!empty($data)) $data .=","; $data .= " `{$k}`='{$v}' "; } } if(empty($id)){ $sql = "INSERT INTO `registration_list` set {$data} "; }else{ $sql = "UPDATE `registration_list` set {$data} where id = '{$id}' "; } $save = $this->conn->query($sql); if($save){ $rid = !empty($id) ? $id : $this->conn->insert_id; $resp['status'] = 'success'; $data = ""; foreach($_POST as $k =>$v){ if(!in_array($k,array('id','registration_code','client_id','schedule','action_user_id','status'))){ if(!empty($data)) $data .=","; $data .= "('{$rid}','{$k}','{$v}')"; } } if(!empty($data)){ $this->conn->query("DELETE FROM `registration_details` where registration_id = '{$rid}' and (meta_field not IN ('groom_image',bride_image))"); $sql2= "INSERT INTO `registration_details` (`registration_id`,`meta_field`,`meta_value`) VALUES {$data}"; $save2 = $this->conn->query($sql2); if($save2){ $resp['status']='success'; if(empty($id)){ $resp["msg"] ="Marriage Registration Successfully added"; }else{ $resp["msg"] ="Marriage Registration Details was Successfully updated"; } $resp['id'] = $rid; }else{ $resp['status'] = 'failed'; $resp['err'] = $this->conn->error."[{$sql2}]"; $resp['msg'] = "An error occured."; $this->conn->query("DELETE FROM `registration_details` where id = '{$rid}'"); } } }else{ $resp['status'] = 'failed'; $resp['msg'] = "An error occured."; $resp['err'] = $this->conn->error."[{$sql}]"; } if($resp['status'] =='success' && (isset($_FILES['img']))){ foreach($_FILES['img']['tmp_name'] as $k=> $v){ if(!empty($_FILES['img']['tmp_name'][$k])){ $fname = "uploads/{$k}-".$rid.'.png'; $dir_path =base_app. $fname; $upload = $_FILES['img']['tmp_name'][$k]; $type = mime_content_type($upload); $allowed = array('image/png','image/jpeg'); if(!in_array($type,$allowed)){ $resp['msg'].=" {$k}'s Image failed to upload due to invalid file type."; }else{ $new_height = 200; $new_width = 200; list($width, $height) = getimagesize($upload); $t_image = imagecreatetruecolor($new_width, $new_height); imagealphablending( $t_image, false ); imagesavealpha( $t_image, true ); $gdImg = ($type == 'image/png')? imagecreatefrompng($upload) : imagecreatefromjpeg($upload); imagecopyresampled($t_image, $gdImg, 0, 0, 0, 0, $new_width, $new_height, $width, $height); if($gdImg){ if(is_file($dir_path)) unlink($dir_path); $uploaded_img = imagepng($t_image,$dir_path); imagedestroy($gdImg); imagedestroy($t_image); if($uploaded_img){ $this->conn->query("DELETE FROM `registration_details` where registration_id = '{$rid}' and meta_field='{$k}_image'"); $this->conn->query("INSERT INTO `registration_details` (`registration_id`,`meta_field`,`meta_value`) VALUES ('{$rid}','{$k}_image',Concat('{$fname}?v=',unix_timestamp(CURRENT_TIMESTAMP))) "); } }else{ $resp['msg'].=" {$k}'s Image failed to upload due to unkown reason."; } } } } } if($resp['status'] =='success') $this->settings->set_flashdata('success',$resp['msg']); // echo "<pre>"; // var_dump($_FILES); // echo "</pre>"; // exit; return json_encode($resp); } function delete_marriage_information(){ extract($_POST); $get = $this->conn->query("SELECT * FROM `registration_details` where registration_id = '{$id}' and meta_field in ('groom_image','bride_image')"); $del = $this->conn->query("DELETE FROM `registration_list` where id = '{$id}'"); if($del){ $resp['status'] = 'success'; $this->settings->set_flashdata('success',"Marriage Information has successfully deleted."); while($row = $get->fetch_assoc()){ $img = $row['meta_value']; $img = explode("?",$img)[0]; if(is_file(base_app.$img)) unlink(base_app.$img); } }else{ $resp['status'] = 'failed'; $resp['error'] = $this->conn->error; } return json_encode($resp); } } $Master = new Master(); $action = !isset($_GET['f']) ? 'none' : strtolower($_GET['f']); $sysset = new SystemSettings(); switch ($action) { case 'save_marriage_information': echo $Master->save_marriage_information(); break; case 'delete_marriage_information': echo $Master->delete_marriage_information(); break; default: // echo $sysset->index(); break; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
<style> img.cimg{ height: 15vh; width: 15vh; object-fit: scale-down; object-position: center; } </style> <?php if(isset($_GET['id'])){ $qry = $conn->query("SELECT * FROM registration_list where id = '{$_GET['id']}' "); if($qry->num_rows > 0){ foreach($qry->fetch_array() as $k=>$v){ $$k= $v; } $qry_meta = $conn->query("SELECT * FROM registration_details where registration_id = '{$id}'"); while($row = $qry_meta->fetch_assoc()){ ${$row['meta_field']} = $row['meta_value']; } }else{ echo "<script>alert('Unkown Registration ID');location.replace('./');</script>"; exit; } $bride = "{$bride_firstname} {$bride_middlename} {$bride_lastname}"; $groom = "{$groom_firstname} {$groom_middlename} {$groom_lastname}"; } ?> <div class="card rounded-0 card-outline card-primary shadow"> <div class="card-header rounded-0"> <h5 class="card-title"> <?php echo !isset($_GET['id']) ? "Create New Registration" : "Update Registration Details".(isset($registration_code)? " - <span class='text-info'>{$registration_code}</span>" : "") ?> </h5> </div> <div class="card-body rounded-0"> <form action="" id="mregistration-form"> <input type="hidden" name="id" value="<?= isset($id) ? $id : '' ?>"> <div class="col-12"> <fieldset> <legend class="text-dark">Groom's Information</legend> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="groom_firstname" class="control-label text-info">Firstname</label> <input type="text" name="groom_firstname" id="groom_firstname" class="form-control border-0 border-bottom rounded-0" required value="<?= isset($groom_firstname) ? $groom_firstname : '' ?>" autofucos> </div> <div class="form-group"> <label for="groom_middlename" class="control-label text-info">Middlename</label> <input type="text" name="groom_middlename" id="groom_middlename" class="form-control border-0 border-bottom rounded-0" value="<?= isset($groom_middlename) ? $groom_middlename : '' ?>" palceholder="optional"> </div> <div class="form-group"> <label for="groom_lastname" class="control-label text-info">Lastname</label> <input type="text" name="groom_lastname" id="groom_lastname" class="form-control border-0 border-bottom rounded-0" value="<?= isset($groom_lastname) ? $groom_lastname : '' ?>" required> </div> <div class="form-group"> <label for="groom_dob" class="control-label text-info">Date of Birth</label> <input type="date" name="groom_dob" id="groom_dob" class="form-control border-0 border-bottom rounded-0" value="<?= isset($groom_dob) ? $groom_dob : '' ?>" required> </div> <div class="form-group"> <label for="groom_religion" class="control-label text-info">Religion</label> <input type="text" name="groom_religion" id="groom_religion" class="form-control border-0 border-bottom rounded-0" value="<?= isset($groom_religion) ? $groom_religion : '' ?>" required> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="groom_permanent_address" class="control-label text-info">Permanent Address</label> <textarea rows="2" name="groom_permanent_address" id="groom_permanent_address" class="form-control border-0 border-bottom rounded-0" style="resize:none" required><?= isset($groom_permanent_address) ? $groom_permanent_address : '' ?></textarea> </div> <div class="form-group"> <label for="groom_present_address" class="control-label text-info">Present Address</label> <textarea rows="2" name="groom_present_address" id="groom_present_address" class="form-control border-0 border-bottom rounded-0" style="resize:none" required><?= isset($groom_present_address) ? $groom_present_address : '' ?></textarea> </div> <div class="form-group d-flex justify-content-center"> <img src="<?php echo validate_image(isset($groom_image) ? $groom_image : "") ?>" alt="" class="img-fluid img-thumbnail border bg-black groom cimg"> </div> <div class="form-group"> <div class="custom-file"> <input type="file" class="custom-file-input rounded-circle" id="customFile" name="img[groom]" onchange="displayImg(this,$(this),$('.cimg.groom'))"> <label class="custom-file-label" for="customFile">Choose file</label> </div> </div> </div> </div> <hr> </fieldset> <fieldset> <legend class="text-dark">Bride's Information</legend> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="bride_firstname" class="control-label text-info">Firstname</label> <input type="text" name="bride_firstname" id="bride_firstname" class="form-control border-0 border-bottom rounded-0" required value="<?= isset($bride_firstname) ? $bride_firstname : '' ?>" autofucos> </div> <div class="form-group"> <label for="bride_middlename" class="control-label text-info">Middlename</label> <input type="text" name="bride_middlename" id="bride_middlename" class="form-control border-0 border-bottom rounded-0" value="<?= isset($bride_middlename) ? $bride_middlename : '' ?>" palceholder="optional"> </div> <div class="form-group"> <label for="bride_lastname" class="control-label text-info">Lastname</label> <input type="text" name="bride_lastname" id="bride_lastname" class="form-control border-0 border-bottom rounded-0" value="<?= isset($bride_lastname) ? $bride_lastname : '' ?>" required> </div> <div class="form-group"> <label for="bride_dob" class="control-label text-info">Date of Birth</label> <input type="date" name="bride_dob" id="bride_dob" class="form-control border-0 border-bottom rounded-0" value="<?= isset($bride_dob) ? $bride_dob : '' ?>" required> </div> <div class="form-group"> <label for="bride_religion" class="control-label text-info">Religion</label> <input type="text" name="bride_religion" id="bride_religion" class="form-control border-0 border-bottom rounded-0" value="<?= isset($bride_religion) ? $bride_religion : '' ?>" required> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="bride_permanent_address" class="control-label text-info">Permanent Address</label> <textarea rows="2" name="bride_permanent_address" id="bride_permanent_address" class="form-control border-0 border-bottom rounded-0" style="resize:none" required><?= isset($bride_permanent_address) ? $bride_permanent_address : '' ?></textarea> </div> <div class="form-group"> <label for="bride_present_address" class="control-label text-info">Present Address</label> <textarea rows="2" name="bride_present_address" id="bride_present_address" class="form-control border-0 border-bottom rounded-0" style="resize:none" required><?= isset($bride_present_address) ? $bride_present_address : '' ?></textarea> </div> <div class="form-group d-flex justify-content-center"> <img src="<?php echo validate_image(isset($bride_image) ? $bride_image : "") ?>" alt="" class="img-fluid img-thumbnail border bg-black bride cimg"> </div> <div class="form-group"> <div class="custom-file"> <input type="file" class="custom-file-input rounded-circle" id="customFile" name="img[bride]" onchange="displayImg(this,$(this),$('.cimg.bride'))"> <label class="custom-file-label" for="customFile">Choose file</label> </div> </div> </div> </div> <hr> </fieldset> <fieldset> <legend class="text-dark">Witnesses</legend> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label class="text-info" for="witness1_name">Name</label> <input type="text" name="witness1_name" id="witness1_name" class="form-control border-0 border-bottom rounded-0" value="<?= isset($witness1_name) ? $witness1_name : '' ?>" required> </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="text-info" for="witness1_address">Address</label> <input type="text" name="witness1_address" id="witness1_address" class="form-control border-0 border-bottom rounded-0" value="<?= isset($witness1_address) ? $witness1_address : '' ?>" required> </div> </div> </div> <hr> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label class="text-info" for="witness2_name">Name</label> <input type="text" name="witness2_name" id="witness2_name" class="form-control border-0 border-bottom rounded-0" value="<?= isset($witness2_name) ? $witness2_name : '' ?>" required> </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="text-info" for="witness2_address">Address</label> <input type="text" name="witness2_address" id="witness2_address" class="form-control border-0 border-bottom rounded-0" value="<?= isset($witness2_address) ? $witness2_address : '' ?>" required> </div> </div> </div> <hr> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label class="text-info" for="witness3_name">Name</label> <input type="text" name="witness3_name" id="witness3_name" class="form-control border-0 border-bottom rounded-0" value="<?= isset($witness3_name) ? $witness3_name : '' ?>" required> </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="text-info" for="witness3_address">Address</label> <input type="text" name="witness3_address" id="witness3_address" class="form-control border-0 border-bottom rounded-0" value="<?= isset($witness3_address) ? $witness3_address : '' ?>" required> </div> </div> </div> <hr> </fieldset> <div class="col-md-6"> <div class="form-group"> <label class="text-info" for="schedule">Marriage Date</label> <input type="date" name="schedule" id="schedule" class="form-control border-0 border-bottom rounded-0" value="<?= isset($schedule) ? $schedule : '' ?>" required> </div> </div> </div> </form> </div> <div class="card-footer text-center rounded-0"> <button class="btn btn-primary rounded-0" type="submit" form="mregistration-form">Save</button> <a href="./" class="btn btn-light border-secondary rounded-0">Cancel</a> </div> </div> <script> function displayImg(input,_this,image) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { image.attr('src', e.target.result); _this.siblings('label').text(input.files[0].name) } reader.readAsDataURL(input.files[0]); }else{ image.attr('src', "<?php echo validate_image('') ?>"); _this.siblings('label').text('Choose file') } } $(function(){ $('#mregistration-form').submit(function(e){ e.preventDefault(); var _this = $(this) start_loader(); $.ajax({ url:_base_url_+"classes/Master.php?f=save_marriage_information", data: new FormData($(this)[0]), cache: false, contentType: false, processData: false, method: 'POST', type: 'POST', dataType: 'json', error:err=>{ console.log(err) alert_toast("An error occured",'error'); end_loader(); }, success:function(resp){ if(typeof resp =='object' && resp.status == 'success'){ location.replace("./?page=view_registration&id="+resp.id); }else if(resp.status == 'failed' && !!resp.msg){ var el = $('<div>') el.addClass("alert alert-danger err-msg").text(resp.msg) _this.prepend(el) el.show('slow') end_loader() }else{ alert_toast("An error occured",'error'); end_loader(); console.log(resp) } $('html,body').animate({scroolTop:0},'fast') } }) }) }) </script> |