Beispiel #1
0
require 'library/twilio-php/Services/Twilio.php';
require_once 'resources/db_connection.php';
require 'db_functions.php';
require 'process_data.php';
if (!isset($_SESSION['token'])) {
    $_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!"));
Beispiel #2
0
<?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';
?>