Skip to content

Commit

Permalink
Merge pull request #1 from stansakl/master
Browse files Browse the repository at this point in the history
Merge to my Suraj Repo
  • Loading branch information
surajmoorthy committed Nov 6, 2017
2 parents bbc31c3 + 0884691 commit 49410a4
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.zip
8 changes: 8 additions & 0 deletions DB/project_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE IF NOT EXISTS `voluntrack`.`USER_PROJECT` (
`USER_ID` INT UNSIGNED NOT NULL,
`PROJECT_ID` INT UNSIGNED NOT NULL,
`PROJECT_START_DATE_TIME` DATETIME(0) NOT NULL,
`PROJECT_END_DATE_TIME` DATETIME(0) NOT NULL,
INDEX `PROJECT_ID_idx` (`PROJECT_ID` ASC, `USER_ID` ASC),
INDEX `User_id _idx` (`USER_ID` ASC))
ENGINE = InnoDB;
8 changes: 8 additions & 0 deletions DB/user_project_db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE IF NOT EXISTS `user_project` (
`USER_ID` int(10) unsigned NOT NULL,
`PROJECT_ID` int(10) unsigned NOT NULL,
`PROJECT_START_DATE_TIME` datetime NOT NULL,
`PROJECT_END_DATE_TIME` datetime NOT NULL,
KEY `User_id _idx` (`USER_ID`),
KEY `PROJECT_ID_idx` (`PROJECT_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
10 changes: 8 additions & 2 deletions src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@
//echo phpinfo();
//var_dump($_SESSION);
if(isset($_SESSION['logged_in']) && ($_SESSION['logged_in'] == true)) {
echo "<a href=\"voluntrack/logout.php\">Logout</a>";
echo "<a href=\"voluntrack/logout.php\">Logout</a><br>";
}
else {
echo "<a href=\"voluntrack/login_view.php\">Login</a>";
echo "<a href=\"voluntrack/login_view.php\">Login</a><br>";
echo "<a href=\"voluntrack/register_view.php\">Register</a>";
}

if(isset($_SESSION['logged_in']) && ($_SESSION['logged_in'] == true)) {
echo "<a href=\"voluntrack/timeentry_view.php\">Enter Time</a><br>";
}
?>


</body>
12 changes: 5 additions & 7 deletions src/voluntrack/DBManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ public static function get_instance() {
private function connect_to_database($value='')
{
$servername = "localhost";
//$servername = "aa10nntj8dofc1n.cixyo4eg79dc.us-east-2.rds.amazonaws.com";
$username = "voluntrack";
$password = "voluntrack";
$conn = null;


try
Expand All @@ -47,7 +49,7 @@ private function connect_to_database($value='')
//echo "Connected successfully";

}
catch(PDOException $e)
catch(\PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
Expand Down Expand Up @@ -79,12 +81,11 @@ public function register_user($first, $last, $middle, $username, $password)
$stmt->execute();

} catch (\Exception $e) {
throw new \Exception("Error registering user. Username may not be unique!", 1);
throw new \Exception("Error registering user!", 1);

}
}

<<<<<<< HEAD
/**
* Returns 1 if user is allowed to login, else 0;
*/
Expand All @@ -94,7 +95,7 @@ public function attempt_login($user, $password)
$hash = password_hash($password, PASSWORD_DEFAULT);

try {
$conn = self::get_connection();
$conn = $this->get_connection();
$stmt = $conn->prepare("SELECT USERNAME, PASSWORD FROM USERS WHERE USERNAME = :username");
$stmt->bindParam(':username', $user);
$stmt->execute();
Expand All @@ -117,8 +118,5 @@ public function attempt_login($user, $password)
} catch (\Exception $e) {
throw $e;
}

=======
>>>>>>> register_user
}
}
6 changes: 4 additions & 2 deletions src/voluntrack/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
//echo "Registration Logic goes here!";
//session_start();
$dbm = DBManager::get_instance();

/*
if ($_POST['password'] !== $_POST['confirmpwd']) {
echo "Passwords do not match!";
header("location: register.php");
}

*/
try {
$dbm->register_user($_POST['firstname'],$_POST['lastname'],$_POST['middlename'],$_POST['email'],$_POST['password']);
header("location: login.php");

} catch (\Exception $e) {
echo "Cannot register user: " . $e->getMessage();
header("location: register.php");
}
20 changes: 20 additions & 0 deletions src/voluntrack/timeentry_view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
session_start();
require "htmlconstants.php";
//namespace voluntrack;
//require '../vendor/autoload.php';
?>
<?php
?>
<!DOCTYPE html>
<?php echo HEADER; ?>


<body>
<main class="container">
<form class="col-md-12" action="timeentry.php" method="post">
<input type="submit" name="loginbtn" value="Enter My Time">
</form>
</main>

</body>

0 comments on commit 49410a4

Please sign in to comment.