Commit c84053bf by mhasan

create asks for log in

parent 38bbac50
......@@ -4,7 +4,7 @@ require 'Twig/lib/Twig/Autoloader.php';
// $amount = $_POST['amount'];
Twig_Autoloader::register();
// Load twig templating engine
// Loads twig templating engine
$loader = new Twig_Loader_Filesystem('views');
$twig = new Twig_Environment($loader);
......@@ -13,10 +13,10 @@ $twig = new \Twig\Environment($loader, ['debug' => true,]);
$twig->addExtension(new \Twig\Extension\DebugExtension());
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 {
echo $twig->render('create.html');
echo $twig->render('create.html'); // Otherwise login is null, and does not let user access.
}
?>
......
<?php
/*
* Takes task (user input) and inserts into the databse. The name of the data table is also the username.
*/
session_start();
require "db_conn.php";
$e = NULL;
......
<?php
/*
* This takes a task ID and deletes it from the database.
*/
require "db_conn.php";
session_start();
$e = null;
......
......@@ -14,7 +14,7 @@ if (isset($_POST['submit'])) {
if ($isMatch == true) {
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!
}
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