Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $showmessage = '';
- if(isset($_POST['submit'])) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $connection = mysqli_connect("localhost", "root", "", "sedctest");
- if(mysqli_connect_errno()) {
- die('Ne moze da se konektira so baza');
- }
- $password = sha1($password);
- $query = "SELECT * ";
- $query .= "FROM users ";
- $query .= "WHERE korisnicko_ime = '{$username}' AND lozinka = '{$password}' ";
- $query .= "LIMIT 1";
- $admin_set = mysqli_query($connection, $query);
- if(!$admin_set) {
- $showmessage = "Problem pri izvrsuvanje na query!" . mysqli_error($connection);
- }
- else {
- $admin = mysqli_fetch_assoc($admin_set);
- mysqli_free_result($admin_set);
- if($admin) {
- $_SESSION['user_id'] = $admin['idd'];
- header('Location: applications.php');
- }
- else {
- $showmessage = "Greshni username/password";
- }
- }
- mysqli_close($connection);
- }
- ?>
- <html>
- <head>
- <title>Login</title>
- </head>
- <body>
- <form method="POST">
- <p>
- <label for="username">Username</label>
- <input type="text" id="username" name="username" />
- </p>
- <p>
- <label for="username">Author</label>
- <input type="text" id="password" name="password" />
- </p>
- <p>
- <input type="submit" name="submit" value="Submit" />
- </p>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement