forked from duke-libraries/fcn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signupProcessor.php
68 lines (65 loc) · 2.86 KB
/
signupProcessor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* signupProcessor: Handle data from signup.php.
*
* @author William Shaw <william.shaw@duke.edu>
* @author Katherine Jentleson <katherine.jentleson@duke.edu>, designer
* @version 0.1, 10/2012
*
* @param name (via POST): The requested usernam.
* @param password (via POST): Password (first entry)
* @param confirm_password (via POST): Password (Validation entry)
* @param email (via POST): user's email address. Not currently used by the game.
* @param ok_to_use_record (via POST): boolean value indicating whether the player consents to
* have his/her record of gameplay used in research, etc.
*/
$r_username = $_POST['name'];
$r_password = $_POST['password'];
$r_password_confirm = $_POST['confirm_password'];
$r_email = $_POST['email'];
$r_record = $_POST['ok_to_use_record'];
require_once 'game/db.php';
ob_start( );
require 'new/functions.php';
ob_end_clean( );
?>
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script><script type="text/javascript">
google.load( "jquery", "1" );
google.load( "jqueryui", "1" );
</script>
<link rel="stylesheet" type="text/css" href="new/fcn.css"/>
<link rel="stylesheet" type="text/css" href="new/jquery-ui.css"/>
<body style="background-color:#fff;font-size:1em;">
<div style="width:50%;margin-left:auto;margin-right:auto;">
<h1>Signup Results</h1>
<?php
// Possible improvement: all this validation really could be happening via JavaScript
// before form submission.
if ( !isUsernameAvailable( $r_username ) ) {
// See if the username is taken
echo( "Sorry, but the collector name <b>" . $r_username . "</b> is already taken. Please go " );
echo( "<a href=\"javascript:window.history.back();\">back</a> and try again." );
} elseif ( strlen( $r_password ) < 6 ) {
// Minimum password length is 6 characters. Please fix this magic number
echo( "Your password must be at least 6 characters long. Please go " );
echo( "<a href=\"javascript:window.history.back();\">back</a> and try again." );
} elseif ( strcmp( $r_password, $r_password_confirm ) != 0 ) {
// Compare the password and the confirmation password...
echo( "Sorry, but your passwords don't match. Please go " );
echo( "<a href=\"javascript:window.history.back();\">back</a> and try again." );
} elseif ( !isEmailValid( $r_email ) ) {
// Call the isEmailValid() function (defined in functions.php) to see if the email
// matches regexps for a valid address.
echo( "Invalid email address. Please go " );
echo( "<a href=\"javascript:window.history.back();\">back</a> and try again." );
} else {
// Okay, form checks out
createUser( $r_username, $r_password, $r_email, $r_record );
echo( "Welcome to Fantasy Collecting! You can now <a href=\"javascript:window.parent.Shadowbox.close();\">Log in</a> and have a look around." );
}
?>
</div>
</body>
</html>