Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Start the session.
- */
- session_start();
- /**
- * Include ircmaxell's password_compat library.
- */
- require 'password.php';
- /**
- * Include our MySQL connection.
- */
- require 'database.php';
- /**
- * Check if the user is logged in.
- */
- if(!isset($_SESSION['user_id']) || !isset($_SESSION['logged_in'])){
- //User not logged in. Redirect them back to the login.php page.
- header('Location: login.php');
- exit;
- }
- if (isset($_POST['submit'])) {
- $listDescription = (isset($_POST['listDescription'])) ? $_POST['listDescription'] : '';
- $listStatus = (isset($_POST['listStatus'])) ? $_POST['listStatus'] : '';
- $createdDate = date('Y-m-d');
- $query = $pdo->prepare("INSERT INTO lists ('createdDate', 'listDescription', 'listStatus') VALUES (:createdDate, :listDescription, :listStatus)");
- $query->bindParam(':listDescription', $listDescription, PDO::PARAM_STR);
- $query->bindParam(':listStatus', $listStatus, PDO::PARAM_STR);
- $query->bindParam(':createdDate', $createdDate, PDO::PARAM_STR);
- $query->execute();
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>TITLE</title>
- <link rel="stylesheet" href="css/style.css">
- </head>
- </html>
- <body>
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Profile</title>
- <!-- Latest compiled and minified CSS -->
- <link rel="stylesheet" href="css/bootstrap.min.css">
- <link rel="stylesheet" href="css/flatui.css">
- <link rel="stylesheet" href="css/site.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- </head>
- <body>
- <nav class="navbar navbar-default">
- <div class="container-fluid">
- <!-- Brand and toggle get grouped for better mobile display -->
- <div class="navbar-header">
- <a class="navbar-brand" href="#">
- <img class="img-responsive" alt="Brand" src="img/ltda.png" height="25" width="25" style="margin-top: -2px">
- </a>
- <a class="navbar-brand" href="#">Little To Do App</a>
- </div>
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
- <ul class="nav navbar-nav navbar-right">
- <li class="dropdown">
- <button class="btn btn-default dropdown-toggle navbar-btn" value="Hi" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
- <span class="glyphicon glyphicon-cog"></span>
- </button>
- <ul class="dropdown-menu">
- <li><a href="profile.php">Account Settings</a></li>
- <li class="divider"></li>
- <li><a href="lists.php">Lists</a></li>
- <li class="divider"></li>
- <li><a href="logouttest.php">Sign Out</a></li>
- </ul>
- </li>
- </ul>
- </div><!-- /.navbar-collapse -->
- </div><!-- /.container-fluid -->
- </nav>
- <div class="container">
- <h1>
- Your Lists - If you see this number your session is set: <?php echo $_SESSION['user_id'] ?>
- </h1>
- </div>
- <div class="form-group">
- <form class="form-horizontal" action="" method="post">
- <fieldset>
- <!-- List Desription-->
- <div class="form-group">
- <label class="col-md-4 control-label" for="listDescription"></label>
- <div class="col-md-4">
- <div class="input-group">
- <span class="input-group-addon">Title / Description</span>
- <input id="listDescription" name="titleDescription" class="form-control" placeholder="Title / Descriptiopn" type="text" required="">
- </div>
- </div>
- </div>
- <!-- List Status -->
- <div class="form-group">
- <label class="col-md-4 control-label" for="listStatus"></label>
- <div class="col-md-4">
- <select id="listStatus" name="listStatus" class="form-control">
- <option value="1">In Progress</option>
- <option value="2">On Hold</option>
- <option value="3">Complete</option>
- </select>
- </div>
- </div>
- <!-- Submit Button -->
- <div class="form-group">
- <label class="col-md-4 control-label" for="btnAddList"></label>
- <div class="col-md-4">
- <input type="submit" id="submit" name="submit" class="btn btn-info" value="Create List">
- </div>
- </div>
- </fieldset>
- </form>
- </div>
- <div class="container">
- <table class="table table-striped table-hover">
- <thead>
- <tr>
- <th>
- Created On
- </th>
- <th>
- Title / Description
- </th>
- <th>
- Status
- </th>
- <th>
- Edit
- </th>
- <th>
- Delete
- </th>
- </tr>
- </thead>
- <tbody>
- <?php
- $result = $pdo->query("SELECT listDescription, createdDate, listStatus FROM `lists` WHERE user_id = '" . $_SESSION['user_id'] . "'");
- $result->execute();
- while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
- echo "<tr>
- <td>".$createdDate = $row['createdDate']."</td>
- <td>".$listDescription = $row['listDescription']."</td>
- <td>".$listStatus = $row['listStatus']."</td>
- <td><input type='checkbox'></td>
- <td><input type='checkbox'></td>
- </tr>";
- }
- ?>
- </tbody>
- </table>
- </div>
- <?php
- var_dump($_POST)
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement