Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include_once('../includes/config.php');
- include_once('header.php');
- include_once('nav.php');
- include_once('functions.php');
- if (!isset($_SESSION['table']) or !$_SESSION['table']) {
- $_SESSION['message'] = array('warning','No table is specified.');
- header("Location: " . SITEHOME);
- }
- $html = "
- <div class='container' style='max-width:500px;text-align:center'>
- <form id='addrecord' method='post' action='../includes/add_record.php' role='form'>
- <h3>Add Record</h3>
- <div class='form-group'>
- ";
- $sql = "SELECT * FROM " . $_SESSION['table']['name'];
- $result = mysqli_query($_SESSION['dbconn'],$sql);
- $record = mysqli_fetch_array($result);
- $columns = array();
- while ($field = mysqli_fetch_field($result)) {
- $columns[] = $field->name;
- }
- $counter = 0;
- while ($counter < count($columns)) {
- $html .= "
- <label for='" . $columns[$counter] . "'>" . $columns[$counter] . "</label>
- <input type='text' id='" . $columns[$counter] . " name='" . $columns[$counter] . " class='form-control' required autofocus value=''>";
- $counter += 1;
- }
- $html .= "</div>";
- $html .= "
- <input type='hidden' name='table' value='" . $_SESSION['table']['name'] . "'>
- <input type='submit' class='btn btn-lg btn-primary btn-block' type='submit' value='Save' />
- </form>
- <a href='" . SITEHOME . ">Cancel</a>
- </div>
- ";
- print $html;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement