\n"; switch($action) { case "login": if (!$user) echo $form['login']; else { $failed = "
Sisse logimine ebaõnnestus! Proovi uuesti."; db(); $tmp = mysql_query("select * from users where user='$user'") or die("$failed"); $a = mysql_fetch_array($tmp); if ($passwd == $a['password']) { $_SESSION['usr'] = $user; $usr = $_SESSION['usr']; header("Location: leht.php"); } else { session_unset(); session_destroy(); die("$failed"); } } break; case "logout": session_unset(); session_destroy(); header("Location: index.php?action=login"); break; case "register": db(); $tmp = @mysql_query("select * from users where user='$user'"); $a = mysql_fetch_array($tmp); if (!$user) echo $form['reg']; elseif ($passwd != $passwd2) { session_destroy(); echo "\n
Paroolid ei ühti. Proovige uuesti."; } elseif (strlen($firma) < 2) { session_destroy(); echo "\n
Jätsite firma märkimata. Proovige uuesti."; } elseif (sizeof($a) > 0) { session_destroy(); echo "\n
Selle nimega kasutaja on juba olemas. Proovige uuesti."; } else { $tmp = mysql_query("insert into users values ('$user', '$passwd', '$name', '$firma')"); $_SESSION['usr'] = $user; $usr = $_SESSION['usr']; header("Location: leht.php"); } break; default: echo $form['login']; break; } ?>