<?php require_once dirname(__DIR__) . '/resources/db_connection.php'; require dirname(__DIR__) . '/db_functions.php'; require dirname(__DIR__) . '/process_data.php'; if (!isset($_SESSION['pk_admin'])) { header('Location: index.php'); } else { if (isset($_POST['submit'])) { $userId = $_POST['id']; $_SESSION['userName'] = $_POST['userName']; $processData = new ProcessData(); $record = $processData->setData($_POST, $_FILES); $row = $record; // validate $row $errors = $processData->validateData($row, 'update'); // if no error exists after validation then update the employee_details of the user if (!$errors) { $status = update_record($userId, $connection, $row); if (1 == $status) { $_SESSION['message'] = 'Your changes have been saved successfully'; header('Location: admin_home.php'); } else { $_SESSION['message'] = 'Sorry! Unable to save your changes'; header('Location: admin_home.php'); } } } } require dirname(__DIR__) . '/layout/header.php'; ?>
$_SESSION['token'] = md5(uniqid(rand(), true)); } $token = $_SESSION['token']; // check if profile photo's file name is present in the session if (!isset($_SESSION['photo'])) { $photo = ''; } // if the user has submitted the form if (isset($_POST['submit'])) { $processData = new ProcessData(); $record = $processData->setData($_POST, $_FILES, $connection); // set session to store the name of the photo so that we can have the photo // during resubmission (in case of validation errors) $_SESSION['photo'] = $record['photo']; // validate data in $record $errors = $processData->validateData($record, $connection, 'register'); // if no error exists after validation then encrypt the passwords and // enter the details to the database. if (!$errors) { $record['password'] = md5($record['password']); $status = insert_record($record, $connection); if ('success' == $status) { $account_sid = 'AC547de080c3d48ff71283595dc7acbed0'; $auth_token = 'c30e80f20ed4350c71295f9d767b68a5'; $client = new Services_Twilio($account_sid, $auth_token); $client->account->messages->create(array('To' => "+918018770024", 'From' => "+13347210408", 'Body' => "Hi " . $record['firstName'] . "! Thanks for registering to EMS!")); $_SESSION['message'] = 'Registration successful!<br>Please check your email to activate your account.'; } elseif ('failed' == $status) { $_SESSION['message'] = 'Unable to send mail.'; } elseif ('Registration failed' == $status) {
require_once 'resources/db_connection.php'; require 'process_data.php'; require 'db_functions.php'; // check if photo's file name is present in the session if (!isset($_SESSION['photo'])) { $photo = ''; } $row = array(); // if the user has submitted the form if (isset($_POST['update'])) { $userId = $_SESSION['id']; $processData = new ProcessData(); $record = $processData->setData($_POST, $_FILES, $connection); $row = $record; // validate $row $errors = $processData->validateData($row, $connection, 'update'); // if no error exists after validation then update the employee_details of the user if (!$errors) { $status = update_record($userId, $connection, $row); if (1 == $status) { $_SESSION['message'] = 'Your changes have been saved successfully'; header('Location: home.php'); } else { $_SESSION['message'] = 'Sorry! Unable to save your changes'; header('Location: home.php'); } } } else { // populate the fields for editing if user is logged in if (isset($_SESSION['id'])) { $userId = $_SESSION['id'];