Commit c84053bf by mhasan

create asks for log in

parent 38bbac50
...@@ -4,7 +4,7 @@ require 'Twig/lib/Twig/Autoloader.php'; ...@@ -4,7 +4,7 @@ require 'Twig/lib/Twig/Autoloader.php';
// $amount = $_POST['amount']; // $amount = $_POST['amount'];
Twig_Autoloader::register(); Twig_Autoloader::register();
// Load twig templating engine // Loads twig templating engine
$loader = new Twig_Loader_Filesystem('views'); $loader = new Twig_Loader_Filesystem('views');
$twig = new Twig_Environment($loader); $twig = new Twig_Environment($loader);
...@@ -13,10 +13,10 @@ $twig = new \Twig\Environment($loader, ['debug' => true,]); ...@@ -13,10 +13,10 @@ $twig = new \Twig\Environment($loader, ['debug' => true,]);
$twig->addExtension(new \Twig\Extension\DebugExtension()); $twig->addExtension(new \Twig\Extension\DebugExtension());
if(isset($_SESSION['userName'])) { if(isset($_SESSION['userName'])) {
echo $twig->render('create.html', array('login' => "true")); echo $twig->render('create.html', array('login' => "true")); //If user is logged in, the normal page is renderd
} }
else { else {
echo $twig->render('create.html'); echo $twig->render('create.html'); // Otherwise login is null, and does not let user access.
} }
?> ?>
......
<?php <?php
/*
* Takes task (user input) and inserts into the databse. The name of the data table is also the username.
*/
session_start(); session_start();
require "db_conn.php"; require "db_conn.php";
$e = NULL; $e = NULL;
......
<?php <?php
/*
* This takes a task ID and deletes it from the database.
*/
require "db_conn.php"; require "db_conn.php";
session_start(); session_start();
$e = null; $e = null;
......
...@@ -14,7 +14,7 @@ if (isset($_POST['submit'])) { ...@@ -14,7 +14,7 @@ if (isset($_POST['submit'])) {
if ($isMatch == true) { if ($isMatch == true) {
session_start(); session_start();
$_SESSION['userName'] = $_POST['userName']; $_SESSION['userName'] = $_POST['userName']; //Starts the session with the username!
header("location: ../view.php"); //redirects user to view page upon successful login! header("location: ../view.php"); //redirects user to view page upon successful login!
} }
else { else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment