Advertisement
dbcalmada

policies.addrecordpage

Mar 28th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include_once('../includes/config.php');
  4. include_once('header.php');
  5. include_once('nav.php');
  6. include_once('functions.php');
  7.  
  8. if (!isset($_SESSION['table']) or !$_SESSION['table']) {
  9.     $_SESSION['message'] = array('warning','No table is specified.');
  10.     header("Location: " . SITEHOME);
  11. }
  12.  
  13. $html = "
  14.     <div class='container' style='max-width:500px;text-align:center'>
  15.  <form id='addrecord' method='post' action='../includes/add_record.php' role='form'>
  16.  <h3>Add Record</h3>
  17.     <div class='form-group'>
  18.     ";
  19.    
  20.     $sql = "SELECT * FROM " . $_SESSION['table']['name'];
  21.    
  22.     $result = mysqli_query($_SESSION['dbconn'],$sql);
  23.     $record = mysqli_fetch_array($result);
  24.    
  25.     $columns = array();
  26.     while ($field = mysqli_fetch_field($result)) {
  27.         $columns[] = $field->name;
  28.     }
  29.    
  30.     $counter = 0;
  31.     while ($counter < count($columns)) {
  32.         $html .= "
  33.             <label for='" . $columns[$counter] . "'>" . $columns[$counter] . "</label>
  34.             <input type='text' id='" . $columns[$counter] . " name='" . $columns[$counter] . " class='form-control' required autofocus value=''>";
  35.         $counter += 1;
  36.     }
  37.    
  38.     $html .= "</div>";
  39.    
  40.     $html .= "
  41.    
  42.         <input type='hidden' name='table' value='" . $_SESSION['table']['name'] . "'>
  43.         <input type='submit' class='btn btn-lg btn-primary btn-block' type='submit' value='Save' />
  44.  
  45.     </form>
  46.     <a href='" . SITEHOME . ">Cancel</a>
  47. </div>
  48. ";
  49.     print $html;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement