-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from UMaine-ASAP/Login-Controller
Login controller seems good. Like the pull request description said, we may have to change how navigating to urls work.
- Loading branch information
Showing
5 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
//begin session | ||
session_start(); | ||
|
||
//get user file | ||
require_once dirname(__FILE__) . "/../models/user.php"; | ||
|
||
//get the html page ready to be displayed | ||
$page = file_get_contents(dirname(__FILE__) . '/../views/login.html'); | ||
echo $page; | ||
if(isset($_POST['submitLogin'])){ //change submitLogin to the equivalent login.html file | ||
|
||
$user = new User(-1); //User with no user id to give | ||
$user->User_Login($_POST['postName'], $_POST['postPassword']); //check for right credentials | ||
|
||
//if correct credentials, set SESSION variables and go to correct home page | ||
if($user->userID != -1){ | ||
$_SESSION['user'] = $user; | ||
$_SESSION['sessionCheck'] = 'true'; | ||
if ($_SESSION['user']->userType == 'Student'){ | ||
header("location:student_home.php"); | ||
} | ||
else{ | ||
header("location:instructor_home.php"); | ||
} | ||
} | ||
else { | ||
echo "Wrong Username/Password</br>Please try again.</br>"; | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Haggis - Sign In</title> | ||
<link rel="stylesheet" type="text/css" href="stylesheet.css"/> | ||
</head> | ||
<body> | ||
<div id="container"> | ||
<div id="headder"> | ||
<button type="button">Register</button> | ||
</div><!-- end of headder --> | ||
|
||
<div id="login"> | ||
<h2>Login</h2> | ||
<form method='POST' name='login form'> | ||
<input type="text" name='postName' placeholder="Username"/> | ||
<p><input type="password" name='postPassword' placeholder="Password"/></p> | ||
<input type="submit" name='submitLogin' value="Login"></input> | ||
</form> | ||
<p><a href="passwordreset.php">forgot your password?</a></p> | ||
</div> <!-- end of form div--> | ||
|
||
<div id="footer"> | ||
|
||
|
||
</div><!-- end of footer --> | ||
</div><!-- end of container div --> | ||
|
||
|
||
</body> | ||
|
||
|
||
|
||
|
||
|
||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#login{ | ||
background:red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/*haggis stylesheet*/ | ||
body{ | ||
border-style:solid; | ||
border-width:1px; | ||
border-color:black; | ||
} | ||
|
||
#login{ | ||
align:center; | ||
} |