summaryrefslogtreecommitdiff
path: root/www/login.php
diff options
context:
space:
mode:
authoroweissbarth2014-03-16 18:44:49 +0100
committeroweissbarth2014-03-16 18:44:49 +0100
commit3a7ade401b3aff5375b98594eec344ed6766321a (patch)
treeacef5f852cd7b2f5b6b31a0bdd1225b6e9221f5e /www/login.php
parent99e60dae1bb5825a426852860e67b9d00e124161 (diff)
downloadfiles.iamfabulous.de-3a7ade401b3aff5375b98594eec344ed6766321a.tar.gz
Added print_login
Diffstat (limited to 'www/login.php')
-rwxr-xr-xwww/login.php61
1 files changed, 32 insertions, 29 deletions
diff --git a/www/login.php b/www/login.php
index 3207703..a9f6f70 100755
--- a/www/login.php
+++ b/www/login.php
@@ -3,52 +3,55 @@
Displays the login page and possible errors. Users can enter their username and password to login. TODO recover Password
It has already been checked that the user isn't already logged in.
- $_GET["reason"] can have the following values:
+ $case can have the following values:
- failure: Specifies that the username and password didn't match. The user is not logged in.
+ LOGIN_PASSWORD: Specifies that the username and password didn't match. The user is not logged in.
- database: Specifies that the request could not be fullfilled due to a database error. The user is not logged in.
+ LOGIN_DATABASE: Specifies that the request could not be fullfilled due to a database error. The user is not logged in.
- succuss: Specifies that the request was successfull. TODO should probably redirect to user root.
+ LOGOUT_SUCCESSFULL: Specifies that user has been logged out.
$_GET["username"] contains the username if a prior attempt to login wasn't successfull.
==================================================================================================================================================
*/
-?>
-<?php include("static/header.html");?>
+function print_login($case){
+
+ include("static/header.html");
- <link rel="stylesheet" type="text/css" href="/static/login.css">
+ $username = isset($_POST['username']) ? $_POST['username'] : "";
- <div class="login-area">
- <h1 class="login-area"> Log in </h1>
- <div class="login-area" id="login-info-bar">
- <?php if(isset($_GET['reason']) && $_GET['reason'] == 'failure' && isset($_GET['username'])){
- echo '<h1 id="login-error"> Invalid username or password </h1>
- ';
- }elseif(isset($_GET['reason']) && $_GET['reason'] == 'logout'){
- echo '<h1 id="logout-message"> Sucessfully logged out.</h1>
+ switch($case){
+ case(LOGIN_PASSWORD):
+ $message = '<h1 id="login-error"> Invalid username or password </h1>
';
- }elseif(isset($_GET['reason']) && $_GET['reason'] == 'database'){
- echo '<h1 id="login-error"> Internal Error. Please contact admin</h1>
+ break;
+ case(LOGIN_DATABASE):
+ $message = '<h1 id="login-error"> Internal Error. Please contact admin</h1>
';
- }?>
- </div>
- <form id="login-form" method='post' action='/login'>
- <?php if(isset($_GET['reason']) && $_GET['reason'] == 'failure' && isset($_GET['username'])){
- echo '<input type="text" placeholder="username" name="username" id="username-input" class="login-input" value="'.$_GET['username'].'"required>
+ break;
+ case(LOGOUT_SUCCESSFULL):
+ $message = '<h1 id="logout-message"> Sucessfully logged out.</h1>
';
- }else{
- echo '<input type="text" placeholder="username" name="username" id="username-input" class="login-input" required>
- ';
- }?>
+ break;
+ }
+
+ echo '<link rel="stylesheet" type="text/css" href="/static/login.css">
+ <div class="login-area">
+ <h1 class="login-area"> Log in </h1>
+ <div class="login-area" id="login-info-bar">'
+ .isset($message)? $message : "".
+ '</div>
+ <form id="login-form" method="post" action="/login">
+ <input type="text" placeholder="username" name="username" id="username-input" class="login-input" value="'. $username .'" required>
<input type="password" placeholder="password" name="password" id="password-input" class="login-input" required>
-
<input type="submit" name="login" id="button-input" class="login-input" value="login">
<a href="recover-password.php" id="recover-password-link">recover password</a>
</form>
- </div>
+ </div>';
-<?php include("static/footer.html");?>
+ include("static/footer.html");
+}
+?>