-
Notifications
You must be signed in to change notification settings - Fork 0
/
register_new.php
64 lines (56 loc) · 1.44 KB
/
register_new.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
<?php
require_once('bamding_fns.php');
$email=$_POST['email'];
$passwd=$_POST['password'];
$passwd2=$_POST['password2'];
session_start();
try
{
//check forms filled in
if(!filled_out($_POST))
{
throw new Exception(
"You have not filled the form out correctly" .
"-- Please go back and try again.");
}
//email address not valid
if( !valid_email($email))
{
throw new Exception(
"That is not a valid email address." .
" Please go back and try again.");
}
//passwords not the same
if( $passwd != $passwd2 )
{
throw new Exception(
"The passwords you entered do not match. " .
"Go back and try again.");
}
//check if password length is okay
//okay if username truncates, but passwords will get munged
//if too long
if( (strlen($passwd)) < 6 || (strlen($passwd)) > 16 )
{
throw new Exception(
"Your password must be between 6 and 16 characters. " .
"Go back and try again.");
}
//attempt to register
//this function can also throw an exception
register($email, $passwd);
//register session variable
$_SESSION['valid_user']= $email;
//provide link to members page
do_html_header('Registration successful');
echo "Your registration was successful. Go to the members page to start.";
do_html_url("member.php", "Go to members page");
do_html_footer();
}
catch(Exception $e)
{
do_html_header("Problem: ");
echo $e->getMessage();
do_html_footer();
exit;
}