|
Registration Form
# Страхуемся
$surname = trim($HTTP_GET_VARS['surname']);
$name = trim($HTTP_GET_VARS['name']);
$age = $HTTP_GET_VARS['age'];
$email = trim($HTTP_GET_VARS['email']);
if (isset($HTTP_GET_VARS['subscribe'])) {
$subscribe = "y";
} else {
$subscribe = "n";
}
$organization = trim($HTTP_GET_VARS['organization']);
$attitude = trim($HTTP_GET_VARS['attitude']);
$username = $HTTP_GET_VARS['username'];
$passwd = $HTTP_GET_VARS['passwd'];
$repasswd = $HTTP_GET_VARS['repasswd'];
$submit = $HTTP_GET_VARS['submit'];
function msg ($msg, $again = 0) {
echo("$msg");
if ($again) {
echo(" Try again!");
}
echo(" ");
}
function set ($var) {
if ($var == '') {
$var = "NULL";
} else {
$var = "'$var'";
}
return $var;
}
function mkbody ($name, $age, $email, $subscribe, $organization, $attitude, $username, $passwd) {
$date = date("d.m.Y");
if ($age != "") {
$age = " ($age)";
}
if ($subscribe!= "n") {
$subscribe = " (Подписка на рассылку)";
} else {
$subscribe = "";
}
if ($organization != "") {
$organization = "Организация: $organization\n";
}
if ($attitude != "") {
$attitude = "Отношение к миротворческим отперациям:\n$attitude\n";
}
return $body = "Имя: $name$age\nE-mail: $email$subscribe\n\n$organization$attitude\nЛогин:\t$username\nПароль:\t$passwd\n\nДата регистрации: $date";
}
$signature = "\n\nС уважением,\nСлужба поддержки\n(http://www.un-museum.ru)";
if (isset($submit)) {
if (!$surname || !ereg("[^0-9]+", $surname)) {
msg("You didn't log in your surname!", 1);
} else {
if (!$name || !ereg("[^0-9]+", $name)) {
msg("You didn't log in your name!", 1);
} else {
if (!$email) {
msg("You didn't log in your e-mail!", 1);
} else {
if (!ereg("^.+@.+\.[a-zA-Z]{2,}$", $email)) {
msg("Your e-mail is not correct!", 1);
} else {
if (!$username) {
msg("You didn't log in your login!", 1);
} else {
if (!ereg("^[a-zA-Z0-9_\-\.]{5,20}$", $username)) {
msg("You logged in incorrect login!", 1);
} else {
if (!$passwd) {
msg("You didnot log in the password!", 1);
} else {
if (!ereg("^[a-zA-Z0-9_\-\.]{5,20}$", $passwd)) {
msg("Your password is not correct!", 1);
} else {
if (!$repasswd) {
msg("You didnot repeat your password!", 1);
} else {
if ($passwd != $repasswd) {
msg("You repeated password not correctly!", 1);
} else {
if (!($connection = @mysql_connect($db_host, $db_user, $db_passwd))) {
msg("It is not possible now to contact the database server!", 1);
} else {
if (!@mysql_select_db($db_name, $connection)) {
msg("It is not possible to contact the database!", 1);
} else {
$verify_query = "SELECT * FROM users WHERE username = '$username';";
$verify = @mysql_query($verify_query);
if (mysql_num_rows($verify) > 0) {
msg("This login already exists!", 1);
} else {
$full_name = "$name $surname";
$age2 = set($age);
$organization2 = set($organization);
$attitude2 = set($attitude);
$reg_date = date("Y-m-d");
$query = "INSERT INTO users VALUES (NULL, '$full_name', $age2, $organization2, $attitude2, '$email', '$subscribe', '$reg_date', '$username', '$passwd');";
if (!@mysql_query($query, $connection)) {
msg("It is not possible to add data!", 1);
} else {
$body = mkbody($full_name, $age, $email, $subscribe, $organization, $attitude, $username, $passwd);
mail("director@un-museum.ru", "Новый пользователь в системе", "$body$signature", "From: Служба поддержки \nContent-Type: text/plain;\n\tcharset=\"windows-1251\"");
$body_user = "Welcome, $name!\n\nYou have been registered on web-site of the Museum of Peacekeeping Operations.\nThank you! Now you can enter the database of the Gallery of Honour of the Museum\n(http://un-museum.ru/deyatel/gallery/).\n\nYour login:\t$username\nYour password:\t$passwd\n\nThank you,\nUN-Museum.ru Support\n(http://www.un-museum.ru)";
mail($email, "Registration on UN-Museum.ru", $body_user, "From: UN-Museum.ru Support \nContent-Type: text/plain;\n\tcharset=\"windows-1251\"");
msg("You registration is completed! Now you can go to "Gallery of Honour" or to section "News"");
}
}
if (!mysql_close($connection)) {
echo("It is not possible to complete connection with data base server!");
}
}
}
}
}
}
}
}
}
}
}
}
}
echo("\n");
} else {
echo("\n");
?>
echo("\n");
} ?>
|