diff options
| author | oweissbarth | 2014-03-16 20:21:32 +0100 |
|---|---|---|
| committer | oweissbarth | 2014-03-16 20:21:32 +0100 |
| commit | 07297d606d209aa4d70d25fe9d72d80e1131c19e (patch) | |
| tree | deb2e29ecf8cfeb23dd743b2d82e4e4d5886b91f /www/register.php | |
| parent | 387a724ccc6eee67deeba93d3021cf3fde7f3730 (diff) | |
| download | files.iamfabulous.de-07297d606d209aa4d70d25fe9d72d80e1131c19e.tar.gz | |
Added print_register
Diffstat (limited to 'www/register.php')
| -rwxr-xr-x | www/register.php | 87 |
1 files changed, 50 insertions, 37 deletions
diff --git a/www/register.php b/www/register.php index 71bd87b..0981c20 100755 --- a/www/register.php +++ b/www/register.php @@ -4,65 +4,78 @@ TODO the email cannot differ from the address the mail was sent to. + TODO Username is not checked for duplicates. + + TODO invites should have it's own error. + 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: - password: Specifies that the password wasn't the same in both fields. The user is not registered. - - database: Specifies that the request could not be fullfilled due to a database error. The user is not registered. - - encoding: Specifies that the request could not be fullfilled due to invalid symbols in the password. TODO we should support the whole UTF-8 - - prohibited: Specifies that the request could not be fullfilled because the account has been marked "blocked" + REGISTER_PASSWORD: Specifies that the password wasn't the same in both fields. The user is not registered. - TODO success? + REGISTER_DATABASE: Specifies that the request could not be fullfilled due to a database error. The user is not registered. - TODO provide the entered data if an error occurred. + REGISTER_EMAIL: Specifies that the request could not be fullfilled due to invalid symbols in the password. - TODO username? + REGISTER_PROHIBITED: Specifies that the request could not be fullfilled because the account has been marked "blocked" - TODO email? - TODO invite-key? - ================================================================================================================================================== +================================================================================================================================================== */ -?> - -<?php include("static/header.html");?> - <link rel="stylesheet" type="text/css" href="/static/register.css"> +function print_register($case){ + include("static/header.html"); - <div class="register-area"> - <h1 class="register-area"> Register </h1> - <div class="register-area" id="register-info-bar"> - <?php if(isset($_GET['reason']) && $_GET['reason'] == 'password'){ - echo '<h1 id="register-error">Passwords don't match</h1> + $username = (isset($_POST["username"]))? $_POST["username"] : ""; + + $email = (isset($_POST["email"]) && $case != REGISTER_EMAIL)? $_POST["email"] : ""; + + $invite_key = isset($_POST["key"])? $_POST["key"] : ""; + + $message = ""; + + switch($case){ + case(REGISTER_PASSWORD): + $message = '<h1 id="register-error">Passwords don't match</h1> '; - }elseif(isset($_GET['reason']) && $_GET['reason'] == 'encoding'){ - echo '<h1 id="register-error">The password contains unsupported characters</h1> + break; + case(REGISTER_DATABASE): + $message = '<h1 id="register-error">Activation of your account is prohibited</h1> '; - }elseif(isset($_GET['reason']) && $_GET['reason'] == 'database'){ - echo '<h1 id="register-error"> Internal Error. Please contact admin</h1> + break; + case(REGISTER_EMAIL): + $message = '<h1 id="register-error">This is not a valid email address</h1> '; - }elseif(isset($_GET['reason']) && $_GET['reason'] == 'prohibited'){ - echo '<h1 id="register-error">Activation of your account is prohibited</h1> + break; + case(REGISTER_PROHIBITED): + $message = '<h1 id="register-error">Activation of your account is prohibited</h1> '; - }?> - </div> - <form id="register-form" action="/register" method='post'> - <input type="text" placeholder="username" name="username" id="username-input" class="register-input" required> + break; + } + + + echo '<link rel="stylesheet" type="text/css" href="/static/register.css"> + + <div class="register-area"> + <h1 class="register-area"> Register </h1> + <div class="register-area" id="register-info-bar">' + .$message. + '</div> + <form id="register-form" action="/register" method="post"> + <input type="text" placeholder="username" name="username" id="username-input" class="register-input" value="'.$username.'" required> <input type="password" placeholder="password" name="pswd" id="password-input" class="register-input" required> <input type="password" placeholder="repeat password" name="2ndpswd" id="password-repeat-input" class="register-input" required> - <input type="text" placeholder="invite-key" name="key" id="key-input" class="register-input" required> - <input type="email" placeholder="email" name="email" id="email-input" class="register-input" required> + <input type="text" placeholder="invite-key" name="key" id="key-input" class="register-input" value="'.$invite_key.'"required> + <input type="email" placeholder="email" name="email" id="email-input" class="register-input" value="'.$email.'"required> <input type="submit" name="register" id="button-input" class="register-input" value="register"> </form> - </div> + </div>'; + include("static/footer.html"); +} -<?php include("static/footer.html");?> |
