/
register.php
132 lines (127 loc) · 5.93 KB
/
register.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/********************************************************************************
* This file is part of eLabChem (http://github.com/martinp23/elabchem) *
* Copyright (c) 2013 Martin Peeks (martinp23@googlemail.com) *
* *
* eLabChem is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* eLabChem is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR *
* PURPOSE. See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public *
* License along with eLabChem. If not, see <http://www.gnu.org/licenses/>. *
* *
* eLabChem is a fork of elabFTW. This file incorporates work covered by the *
* copyright notice below. *
* *
********************************************************************************/
/******************************************************************************
* Copyright 2012 Nicolas CARPi
* This file is part of eLabFTW.
*
* eLabFTW is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* eLabFTW is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with eLabFTW. If not, see <http://www.gnu.org/licenses/>.
*
********************************************************************************/
session_start();
require_once('inc/head.php');
$page_title='Register';
require_once('inc/menu.php');
require_once('inc/info_box.php');
// Check if we're logged in
if (isset($_SESSION['auth']) && $_SESSION['auth'] == 1) {
die("<ul>
<li>Please <a href='logout.php'>logout</a> before you register another account.</li>
</ul>");
}
?>
<!-- Password complexity visualizer -->
<script src="js/jquery.complexify.min.js"></script>
<!-- Form validation client-side -->
<script src="js/parsley.min.js"></script>
<section>
<!-- Register form -->
<form name="regForm" data-validate="parsley" id="regForm" method="post" action="register-exec.php" class='innerinnerdiv'>
<fieldset>
<legend>Create your account :</legend>
<p>
<label for="firstname">Firstname</label>
<input name="firstname" type="text" id="firstname" data-trigger="change" data-required="true" />
</p>
<p>
<label for="lastname">Lastname</label>
<input name="lastname" type="text" id="lastname" data-trigger="change" data-required="true" />
</p>
<p>
<label for="username">Username</label>
<input name="username" type="text" id="username" data-trigger="change" data-required="true" />
</p>
<p>
<label for="email">Email</label>
<input name="email" type="email" id="email" data-trigger="change" data-required="true" data-type="email" />
</p>
<p>
<label for="password">Password</label>
<input name="password" type="password" id="password" data-trigger="change" data-minlength="4" />
</p>
<p>
<label for="cpassword">Confirm password</label>
<input name="cpassword" type="password" id="cpassword" data-trigger="change" data-equalto="#password" data-error-message="The passwords do not match!" />
</p>
Password complexity (for your information) : <span id="complexity">0%</span><br /><br />
<div id='submitDiv'>
<input type="submit" name="Submit" class='submit' value="Register" />
</div>
</fieldset>
</form>
<!-- end register form -->
</section>
<style>
.parsley-error {
color:red;
background-color:yellow;
}
.parsley-error-list {
color:red;
font-weight:bold;
}
</style>
<script>
$(document).ready(function() {
// give focus to the first field on page load
document.getElementById("firstname").focus();
// password complexity
$("#password").complexify({}, function (valid, complexity){
if (complexity < 30) {
$('#complexity').css({'color':'red'});
} else {
$('#complexity').css({'color':'green'});
}
$("#complexity").html(Math.round(complexity) + '%');
});
// propose username by combining firstname's first letter and lastname
$("#username").focus(function() {
var firstname = $("#firstname").val();
var lastname = $("#lastname").val();
if(firstname && lastname && !this.value) {
this.value = firstname.charAt(0) + lastname;
}
});
});
</script>
<?php require_once('inc/footer.php'); ?>