Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- index.php:
- <?php
- session_start();
- if(!isset($_SESSION['isLogged']))
- {
- header_remove();
- header('Location: login.php');
- die;
- }
- echo "Te-ai logat cu succes! </br>";
- echo "<a href=\"logout.php\">Logout</a>";
- ?>
- login.php:
- <?php
- session_start();
- include 'config.php';
- if(isset($_SESSION['isLogged']))
- {
- header_remove();
- header('Location: index.php');
- die;
- }
- if(isset($_POST["Login"]))
- {
- $Username = $_POST["Username"];
- $Password = $_POST["Password"];
- $stmt = $pdo->query("SELECT * FROM admin");
- $adminArray = $stmt->fetch();
- if($adminArray['Utilizator'] == $Username && $adminArray['Parola'] == $Password)
- {
- $_SESSION['isLogged']= $Username;
- echo '<script type="text/javascript">windows.open("index.php","_self");</script>';
- }
- }
- ?>
- <html>
- <body>
- <form action="" method="post">
- <center>
- <label><b>Utilizator: </b></label>
- <input type="text" name="Username">
- <label><b>Password: </b></label>
- <input type="password" name="Password">
- <input type="submit" value="LOGIN" name="Login">
- </center>
- </form>
- </body>
- </html>
- logout.php:
- <?php
- session_start();
- if(isset($_SESSION['isLogged']))
- session_destroy();
- else
- {
- header_remove();
- header('Location: login.php');
- die;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement