0byt3m1n1
Path:
/
var
/
www
/
listcrawler.app
/
public_html
/
admin
/
[
Home
]
File: add_subarea.php
<?php session_start(); require_once 'config/config.php'; require_once BASE_PATH.'/includes/auth_validate.php'; // Serve POST method, After successful insert, redirect to lists.php page. if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Mass Insert Data. Keep "name" attribute in html form same as column name in mysql table. $data_to_db = array_filter($_POST); $db = getDbInstance(); $last_id = $db->insert('subareas', $data_to_db); if ($last_id) { $_SESSION['success'] = 'Sub area added successfully!'; // Redirect to the edit page header('Location: edit_subarea.php?subarea_id=' . $last_id . '&operation=edit'); // Important! Don't execute the rest put the exit/die. exit(); } else { echo 'Insert failed: ' . $db->getLastError(); exit(); } } $db = getDbInstance(); $getLocations = $db->rawQuery("SELECT `id`, `location_name` FROM `locations` ORDER BY `location_name` ASC "); // We are using same form for adding and editing. This is a create form so declare $edit = false. $edit = false; ?> <?php include BASE_PATH.'/includes/header.php'; ?> <div id="page-wrapper"> <div class="row"> <div class="col-lg-6"> <h2 class="page-header">Add a Sub Area</h2> </div> <div class="col-lg-6"> <div class="page-action-links text-right"> <a href="subareas.php" class="btn btn-success"><i class="glyphicon glyphicon-chevron-left"></i> Sub Area Listing</a> </div> </div> </div> <!-- Flash messages --> <?php include BASE_PATH.'/includes/flash_messages.php'; ?> <form class="form" action="" method="post" id="subarea_form" enctype="multipart/form-data"> <?php include BASE_PATH.'/forms/subarea_form.php'; ?> </form> </div> <script type="text/javascript"> $(document).ready(function(){ $('#subarea_form').validate({ rules: { location_id: { required: true }, subarea_name: { required: true, minlength: 3 } } }); }); </script> <?php include BASE_PATH.'/includes/footer.php'; ?>