forked from open-austin/council-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
executable file
·46 lines (27 loc) · 1.15 KB
/
signup.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
<?php // signup.php
session_start();
$_SESSION ['err'] = '';
require_once 'Util.php';
require_once 'User.php';
$atxcc_us = new User ();
if ($_POST) {
$username = $_POST ['username'];
$password = $_POST ['password'];
$email = $_POST ['email'];
$mobile = preg_replace ('/[^\d]/', "", $_POST ['mobile']);
$err = '';
$server = $_SERVER ['SERVER_NAME'];
$urlRedirect = 'http://' . $server . '/atxcc';
if ($atxcc_us -> getIdx ($username)) {
$err = "user: '$username' already exists";
$urlRedirect = $urlRedirect . '/signup';
} elseif (strlen ($mobile) != 10) {
$err = "The mobile number can have any puntuation you want, but must have exactly 10 digits. i.e. (512)555-1212 or 512.555.1212 or 512-555-1212 or 512!555xyz1212 will all work";
$urlRedirect = $urlRedirect . '/signup';
} else {
$mobile = preg_replace ('/(\d{3})(\d{3})(\d{4})/', '$1-$2-$3', $mobile);
$atxcc_us -> registerUser ($username, $password, $email, $mobile);
} // end if ($atxcc_us -> getIdx ($username))
$_SESSION ['err'] = $err;
Util::redirect ($urlRedirect);
} // end if ($_POST)