Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @{
- if (IsPost)
- {
- string user = Request.Form["user"];
- string pass = Request.Form["pass"];
- DataClassesDataContext db = new DataClassesDataContext();
- var useri = from a in db.users select a;
- var korisnik = useri.FirstOrDefault(x => x.password == pass && x.username == user);
- if (korisnik != null)
- {
- if (korisnik.role_id == 2) {
- Response.Redirect("Admin.cshtml");
- }
- else
- {
- Session["user"] = user;
- Session["pass"] = pass;
- Session["id"] = korisnik.id+"";
- Response.Redirect("User.cshtml");
- }
- }
- else
- {
- <text>
- fail
- </text>
- }
- }
- }
- <html>
- <head>
- <style>
- #bd {
- background-image: url('img/bg.jpg');
- }
- </style>
- <title>Login</title>
- <link rel="stylesheet" href="css/reset.css">
- <link rel="stylesheet" href="css/animate.css">
- <link rel="stylesheet" href="css/styles.css">
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- </head>
- <body id='bd'>
- <div id='container'>
- <form method='post'>
- <label for="name">Username:</label> <input id='user' type='name' name='user'>
- <label for="username">Password:</label><input id='pass' type='password' name='pass'>
- <input type='submit' value='login' onclick="postavi()">
- </form>
- </div>
- <script type='text/javascript'>
- function postavi(){
- var user = document.getElementById('user').value;
- localStorage.setItem("user", user);
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement