Advertisement
Guest User

New List Submit

a guest
Aug 4th, 2017
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.20 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Start the session.
  5.  */
  6. session_start();
  7.  
  8. /**
  9.  * Include ircmaxell's password_compat library.
  10.  */
  11. require 'password.php';
  12.  
  13. /**
  14.  * Include our MySQL connection.
  15.  */
  16. require 'database.php';
  17.  
  18.  
  19. /**
  20.  * Check if the user is logged in.
  21.  */
  22. if(!isset($_SESSION['user_id']) || !isset($_SESSION['logged_in'])){
  23.     //User not logged in. Redirect them back to the login.php page.
  24.     header('Location: login.php');
  25.     exit;
  26. }
  27.  
  28.     if (isset($_POST['submit'])) {
  29.         $listDescription = (isset($_POST['listDescription'])) ? $_POST['listDescription'] : '';
  30.         $listStatus = (isset($_POST['listStatus'])) ? $_POST['listStatus'] : '';
  31.         $createdDate = date('Y-m-d');
  32.  
  33.         $query = $pdo->prepare("INSERT INTO lists ('createdDate', 'listDescription', 'listStatus') VALUES (:createdDate, :listDescription, :listStatus)");
  34.         $query->bindParam(':listDescription', $listDescription, PDO::PARAM_STR);
  35.         $query->bindParam(':listStatus', $listStatus, PDO::PARAM_STR);
  36.         $query->bindParam(':createdDate', $createdDate, PDO::PARAM_STR);
  37.         $query->execute();
  38.     }
  39.  
  40.  
  41.  
  42. ?>
  43. <!DOCTYPE html>
  44. <html lang="en">
  45. <head>
  46.     <meta charset="utf-8">
  47.     <title>TITLE</title>
  48.     <link rel="stylesheet" href="css/style.css">
  49.  
  50. </head>
  51. </html>
  52. <body>
  53.  
  54.  
  55. <!doctype html>
  56. <html lang="en">
  57. <head>
  58.     <meta charset="UTF-8">
  59.     <title>Profile</title>
  60.     <!-- Latest compiled and minified CSS -->
  61.     <link rel="stylesheet" href="css/bootstrap.min.css">
  62.     <link rel="stylesheet" href="css/flatui.css">
  63.     <link rel="stylesheet" href="css/site.css">
  64.  
  65.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  66.     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  67. </head>
  68. <body>
  69. <nav class="navbar navbar-default">
  70.     <div class="container-fluid">
  71.         <!-- Brand and toggle get grouped for better mobile display -->
  72.         <div class="navbar-header">
  73.             <a class="navbar-brand" href="#">
  74.                 <img class="img-responsive" alt="Brand" src="img/ltda.png" height="25" width="25" style="margin-top: -2px">
  75.             </a>
  76.             <a class="navbar-brand" href="#">Little To Do App</a>
  77.         </div>
  78.  
  79.  
  80.         <!-- Collect the nav links, forms, and other content for toggling -->
  81.         <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  82.             <ul class="nav navbar-nav navbar-right">
  83.                 <li class="dropdown">
  84.                     <button class="btn btn-default dropdown-toggle navbar-btn" value="Hi" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
  85.                         <span class="glyphicon glyphicon-cog"></span>
  86.                     </button>
  87.                     <ul class="dropdown-menu">
  88.                         <li><a href="profile.php">Account Settings</a></li>
  89.                         <li class="divider"></li>
  90.                         <li><a href="lists.php">Lists</a></li>
  91.                         <li class="divider"></li>
  92.                         <li><a href="logouttest.php">Sign Out</a></li>
  93.                     </ul>
  94.                 </li>
  95.             </ul>
  96.         </div><!-- /.navbar-collapse -->
  97.     </div><!-- /.container-fluid -->
  98. </nav>
  99. <div class="container">
  100.     <h1>
  101.         Your Lists - If you see this number your session is set: <?php echo $_SESSION['user_id'] ?>
  102.     </h1>
  103. </div>
  104.  
  105. <div class="form-group">
  106.     <form class="form-horizontal" action="" method="post">
  107.         <fieldset>
  108.             <!-- List Desription-->
  109.             <div class="form-group">
  110.                 <label class="col-md-4 control-label" for="listDescription"></label>
  111.                 <div class="col-md-4">
  112.                     <div class="input-group">
  113.                         <span class="input-group-addon">Title / Description</span>
  114.                         <input id="listDescription" name="titleDescription" class="form-control" placeholder="Title / Descriptiopn" type="text" required="">
  115.                     </div>
  116.                 </div>
  117.             </div>
  118.             <!-- List Status -->
  119.             <div class="form-group">
  120.                 <label class="col-md-4 control-label" for="listStatus"></label>
  121.                 <div class="col-md-4">
  122.                     <select id="listStatus" name="listStatus" class="form-control">
  123.                         <option value="1">In Progress</option>
  124.                         <option value="2">On Hold</option>
  125.                         <option value="3">Complete</option>
  126.                     </select>
  127.                 </div>
  128.             </div>
  129.             <!-- Submit Button -->
  130.             <div class="form-group">
  131.                 <label class="col-md-4 control-label" for="btnAddList"></label>
  132.                 <div class="col-md-4">
  133.                     <input type="submit" id="submit" name="submit" class="btn btn-info" value="Create List">
  134.                 </div>
  135.             </div>
  136.         </fieldset>
  137.     </form>
  138. </div>
  139.  
  140. <div class="container">
  141.     <table class="table table-striped table-hover">
  142.         <thead>
  143.         <tr>
  144.             <th>
  145.                 Created On
  146.             </th>
  147.             <th>
  148.                 Title / Description
  149.             </th>
  150.             <th>
  151.                 Status
  152.             </th>
  153.             <th>
  154.                 Edit
  155.             </th>
  156.             <th>
  157.                 Delete
  158.             </th>
  159.         </tr>
  160.         </thead>
  161.         <tbody>
  162.         <?php
  163.  
  164.         $result = $pdo->query("SELECT listDescription, createdDate, listStatus FROM `lists` WHERE user_id = '" . $_SESSION['user_id'] . "'");
  165.         $result->execute();
  166.  
  167.         while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
  168.             echo    "<tr>
  169.                        <td>".$createdDate = $row['createdDate']."</td>
  170.                        <td>".$listDescription = $row['listDescription']."</td>
  171.                        <td>".$listStatus = $row['listStatus']."</td>
  172.                        <td><input type='checkbox'></td>
  173.                        <td><input type='checkbox'></td>
  174.                    </tr>";
  175.  
  176.         }
  177.         ?>
  178.         </tbody>
  179.     </table>
  180. </div>
  181. <?php
  182. var_dump($_POST)
  183. ?>
  184. </body>
  185. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement