Rev 449 | Rev 505 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
169 | tom | 1 | <?php |
2 | |||
3 | require '_taios.php'; |
||
348 | tom | 4 | require_once '_recaptchalib.php'; |
169 | tom | 5 | |
6 | $page = new Taios_Page('Login'); |
||
7 | |||
8 | $username = $_POST['username']; |
||
9 | $password = $_POST['password']; |
||
10 | $password2 = $_POST['password2']; |
||
11 | $email = $_POST['email']; |
||
12 | $name = $_POST['name']; |
||
449 | tom | 13 | $maths = $_POST['maths']; |
169 | tom | 14 | |
15 | if (empty($username)) |
||
16 | { |
||
17 | $page->redirect('register.php?error=No Username Specified'); |
||
18 | } |
||
19 | if (empty($password)) |
||
20 | { |
||
21 | $page->redirect('register.php?error=No Password Specified'); |
||
22 | } |
||
23 | if (empty($password2)) |
||
24 | { |
||
25 | $page->redirect('register.php?error=No Repeat Password Specified'); |
||
26 | } |
||
27 | if ($password != $password2) |
||
28 | { |
||
29 | $page->redirect('register.php?error=Passwords do not match'); |
||
30 | } |
||
449 | tom | 31 | if ($maths != '75') |
32 | { |
||
33 | $page->redirect('register.php?error=Incorrect maths answer'); |
||
34 | } |
||
355 | tom | 35 | |
356 | tom | 36 | $resp = recaptcha_check_answer(RECAPTCHA_PRIVATEKEY, $_SERVER["REMOTE_ADDR"], |
354 | tom | 37 | $_POST["recaptcha_challenge_field"], |
38 | $_POST["recaptcha_response_field"]); |
||
169 | tom | 39 | |
354 | tom | 40 | if (!$resp->is_valid) |
41 | { |
||
42 | $page->redirect('register.php?error=Incorrect reCAPTCHA response'); |
||
43 | } |
||
44 | |||
492 | tom | 45 | $args = array(2, $username, sha1($password), $email, $name, 0); |
46 | $page->query("INSERT INTO Users (AccessID, Username, Password, EmailAddress, Name, ChallengeID) VALUES (?, ?, ?, ?, ?, ?)", $args); |
||
169 | tom | 47 | |
48 | $page->redirect('login.php'); |
||
49 | |||
50 | ?> |