0byt3m1n1
Path:
/
var
/
www
/
listcrawler.app
/
public_html
/
admin
/
[
Home
]
File: edit_message_api.php
<?php session_start(); require_once 'config/config.php'; require_once BASE_PATH.'/includes/auth_validate.php'; // Sanitize if you want $api_id = filter_input(INPUT_GET, 'api_id', FILTER_VALIDATE_INT); $operation = filter_input(INPUT_GET, 'operation', FILTER_SANITIZE_STRING); ($operation == 'edit') ? $edit = true : $edit = false; $db = getDbInstance(); // Handle update request. As the form's action attribute is set to the same script, but 'POST' method, if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Get api_id form query string parameter. $api_id = filter_input(INPUT_GET, 'api_id', FILTER_SANITIZE_STRING); // Get input data $data_to_db = filter_input_array(INPUT_POST); $listdata_to_db = array( 'base_url' => trim($data_to_db['base_url']), 'var_mobile_title' => trim($data_to_db['var_mobile_title']), 'var_username_title' => trim($data_to_db['var_username_title']), 'var_username_value' => trim($data_to_db['var_username_value']), 'var_password_title' => trim($data_to_db['var_password_title']), 'var_password_value' => trim($data_to_db['var_password_value']), 'var_city_title' => trim($data_to_db['var_city_title']) ); $db = getDbInstance(); $db->where('id', $api_id); $stat = $db->update('api_url', $listdata_to_db); if ($stat) { $_SESSION['success'] = 'API URL updated successfully!'; // Redirect to the edit page header('Location: edit_message_api.php?api_id=' . $api_id . '&operation=edit'); // Important! Don't execute the rest put the exit/die. exit(); } } // If edit variable is set, we are performing the update operation. if ($edit) { $db->where('id', $api_id); // Get data to pre-populate the form. $message_api = $db->getOne('api_url'); } ?> <?php include BASE_PATH.'/includes/header.php'; ?> <div id="page-wrapper"> <div class="row"> <div class="col-lg-12"> <h2 class="page-header">Update Message API URL</h2> </div> </div> <!-- Flash messages --> <?php include BASE_PATH.'/includes/flash_messages.php'; ?> <form class="form" action="" method="post" id="message_api_form.php" enctype="multipart/form-data"> <?php include BASE_PATH.'/forms/message_api_form.php'; ?> </form> </div> <script type="text/javascript"> $(document).ready(function(){ $('#message_api_form.php').validate({ rules: { base_url: { required: true, minlength: 6 }, var_mobile_title: { required: true }, var_username_title: { required: true }, var_username_value: { required: true }, var_password_title: { required: true }, var_password_value: { required: true }, var_city_title: { required: true } } }); }); </script> <?php include BASE_PATH.'/includes/footer.php'; ?>