blob: eeff66c7e4a6208b74476c7069db761caa2e0907 (
plain)
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
|
<?php
/**
* Copyright (c) 2007 Nathan Kinkade
*
* This code is offered under an MIT (X11) license. For more information
* about the terms of this license see the file LICENSE included with this
* software or visit: http://www.opensource.org/licenses/mit-license.php
*/
include "include/db.php";
# make sure that none of the fields are empty
if ($_POST['login']) {
foreach ($_POST as $data) {
if ($data == "") {
$err = "<span class='errors'>You must fill in all fields!</span><br />\n";
$reg_status == "failed";
return;
}
}
}
# make sure that the passwords match
if ($_POST['passwd'] != $_POST['passwd2']) {
$err = "<span class='errors'>Your passwords do not match. Please try again.</span><br />\n";
$reg_status == "failed";
return;
}
# make sure that age is >0 && <100
if ($_POST['age'] < 1 || $_POST['age'] > 100) {
$err = "<span class='errors'>Your age must be between 1 and 100 (years).</span><br />\n";
$reg_status == "failed";
return;
}
$lnk = db_connect();
# make sure that the login does not already exist
$res = db_query("SELECT id_users FROM users WHERE login = '{$_POST['login']}'");
if (db_num_rows($res)) {
$err = "<span class='errors'>Login name '{$_POST['login']}' is already in use. Please select another.</span><br />\n";
$reg_status == "failed";
return;
}
$hashpwd = md5($_POST['passwd']);
$qry = "
INSERT INTO users (login, passwd, age, gender)
VALUES ('{$_POST['login']}','$hashpwd', '{$_POST['age']}', '{$_POST['gender']}')
";
db_query($qry);
$reg_status = "ok_passed";
db_close($lnk);
?>
|