-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnewaccount.php
172 lines (135 loc) · 4.58 KB
/
newaccount.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
/*
* newaccount.php
*
* Allows a user to create a new account
*
*/
session_start();
include_once 'config.php';
include_once 'db.php';
include_once 'lib/utility.php';
$page_title = 'New Account';
$js = 'js/edit_users.js';
include 'header.php';
?>
<div id='content'>
<h1 class="title">New Account Signup Form</h1>
<?php
// Are we being directed to enter the data?
if ( isset( $_POST['enter_request'] ) )
{
// Check if they match
if ( $_POST['captcha'] == $_SESSION['captcha'] )
enter_record();
else
do_captcha( "Entered text does not match." );
}
else if ( isset( $_SESSION['message'] ) )
{
// Then we are being redirected back here from register.php
$message = $_SESSION['message'];
unset( $_SESSION['message'] );
enter_record( $message );
}
else // Just display the captcha
do_captcha();
?>
</div>
<?php
include 'footer.php';
exit();
function enter_record( $message = '' )
{
if ( isset($message) )
{
// Get posted information from register.php
$lname = $_SESSION['POST']['lname'];
$fname = $_SESSION['POST']['fname'];
$organization = $_SESSION['POST']['organization'];
$address = $_SESSION['POST']['address'];
$city = $_SESSION['POST']['city'];
$state = $_SESSION['POST']['state'];
$zip = $_SESSION['POST']['zip'];
$country = $_SESSION['POST']['country'];
$phone = $_SESSION['POST']['phone'];
// email might have been unset
if ( isset( $_SESSION['POST']['email'] ) )
$email = $_SESSION['POST']['email'];
unset( $_SESSION['POST'] );
echo "<p class='message'>$message</p>\n";
}
echo<<<HTML
<p>Please enter your contact information. All fields
are required.</p>
<p class='message'>When entering your address, PLEASE MAKE SURE
it is a valid mailing address, since this will be used to
mail information to you.</p>
<form action="register.php" method="post"
onsubmit='return validate( this );'>
<table cellspacing='0' cellpadding='10'>
<thead>
<tr><th colspan='2'>Personal Information</th></tr>
</thead>
<tfoot>
<tr><td colspan='2'><input type='submit' name='create'
value='Create New Account' /></td></tr>
</tfoot>
<tbody>
<tr><th>First Name:</th>
<td><input type='text' name='fname' size='40'
maxlength='64' value='$fname' /></td></tr>
<tr><th>Last Name:</th>
<td><input type='text' name='lname' size='40'
maxlength='64' value='$lname' /></td></tr>
<tr><th>Organization:</th>
<td><input type='text' name='organization' size='40'
maxlength='128' value='$organization' /></td></tr>
<tr><th>Address:</th>
<td><input type='text' name='address' size='40'
maxlength='128' value='$address' /></td></tr>
<tr><th>City:</th>
<td><input type='text' name='city' size='40'
maxlength='64' value='$city' /></td></tr>
<tr><th>State (Province):</th>
<td><input type='text' name='state' size='40'
maxlength='64' value='$state' /></td></tr>
<tr><th>Postal Code (Zip):</th>
<td><input type='text' name='zip' size='40'
maxlength='16' value='$zip' /></td></tr>
<tr><th>Country:</th>
<td><input type='text' name='country' size='40'
maxlength='64' value='$country' /></td></tr>
<tr><th>Phone:</th>
<td><input type='text' name='phone' size='40'
maxlength='64' value='$phone' /></td></tr>
<tr><th>Email:</th>
<td><input type='text' name='email' size='40'
maxlength='64' value='$email' /></td></tr>
</tbody>
</table>
</form>
HTML;
}
// Function to display a captcha and request human input
function do_captcha( $msg = "" )
{
$message = ( empty( $msg ) ) ? "" : "<p style='color:red;'>$msg</p>";
$act = htmlentities($_SERVER['PHP_SELF']);
// Let's just use the random password function we already have
$pw = makeRandomPassword();
$_SESSION['captcha'] = $pw;
echo<<<HTML
<div id='captcha'>
$message
<img src='create_captcha.php' alt='Captcha image' />
<form action="$act" method="post">
<h3>Please enter the code above to proceed to new account request</h3>
<p><input type='text' name='captcha' size='40' maxlength='10' /></p>
<p><input type='submit' name='enter_request' value='Enter Request' />
<input type='reset' /></p>
</form>
</div>
HTML;
}
?>