From d895b852a6e160496ffc760d46d3719a3d62ff86 Mon Sep 17 00:00:00 2001 From: Nathan Kinkade Date: Sun, 3 Feb 2008 23:23:24 +0000 Subject: Initial checkin of nutridb.org and basic subversion directory structure --- add_user.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 add_user.php (limited to 'add_user.php') diff --git a/add_user.php b/add_user.php new file mode 100644 index 0000000..754c946 --- /dev/null +++ b/add_user.php @@ -0,0 +1,53 @@ +You must fill in all fields!
\n"; + $reg_status == "failed"; + return; + } + } +} + +# make sure that the passwords match +if ($_POST['passwd'] != $_POST['passwd2']) { + $err = "Your passwords do not match. Please try again.
\n"; + $reg_status == "failed"; + return; +} + +# make sure that age is >0 && <100 +if ($_POST['age'] < 1 || $_POST['age'] > 100) { + $err = "Your age must be between 1 and 100 (years).
\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 = "Login name '{$_POST['login']}' is already in use. Please select another.
\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); + +?> -- cgit v1.2.3