0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
ADMIN
/
[
Home
]
File: createuser_ctrl.php
<?php require_once "../model/employee_mdl.php"; // Assuming $server_ip is defined elsewhere in your code $server_ip = "http://localhost"; $salutation = @$_POST['salutation']; $name = @$_POST['txtname']; $username = @$_POST['txtusername']; $password = @$_POST['txtpassword']; $designation = @$_POST['txtdesignation']; $coinvestigator = @$_POST['txtcoinvestigator']; $division = @$_POST['division']; $errors = array(); // Check if required fields are empty if (empty($username)) { $errors['username_null'] = "Please Enter username"; } if (empty($password)) { $errors['password_null'] = "Please Enter password"; } if (empty($name)) { $errors['name_null'] = "Please Enter Name"; } if (empty($designation)) { $errors['designation_null'] = "Please Enter Designation"; } if (empty($salutation)) { $errors['salutation_null'] = "Please Enter Salutation"; } $employee = new Employee(); $result = $employee->userNameCheck($username); if ($result == "True") { $errors['username_exist'] = "Username already exists."; } if (!empty($errors)) { include("createuser.php"); exit(); } $uploadOk = false; if (!empty($_FILES["photo"]["tmp_name"])) { $check = getimagesize($_FILES["photo"]["tmp_name"]); if ($check !== false) { $uploadOk = true; } } if ($uploadOk) { $target_dir = "../photo/"; $ph_name = rand(10000, 99999999) . $_FILES['photo']['name']; $target_file = $target_dir . basename($ph_name); if (move_uploaded_file($_FILES['photo']['tmp_name'], $target_file)) { $employee = new Employee(); $result = $employee->addUser($username, $password, $name, $designation, $salutation, $coinvestigator, $target_file, $division); if ($result == "True") { $message = "Registration Completed successfully.."; $url = $server_ip . "/ADMIN/createuser.php?message=$message"; echo "<script>window.location='$url'</script>"; exit(); } else { $message = "Registration Failed."; } } else { $message = "Photo not uploaded. Registration Failed."; } } else { $message = "Invalid image."; } $url = $server_ip . "/ADMIN/createuser.php?message=$message"; echo "<script>window.location='$url'</script>"; exit(); ?>