Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // INDEX
- <?php
- define('DB_SERVER', 'localhost');
- define('DB_USERNAME', 'root');
- define('DB_PASSWORD', '');
- define('DB_DATABASE', 'logindaten');
- $db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE) or die ("ERROR");
- if($_SERVER["REQUEST_METHOD"] == "POST") {
- // username and password sent from form
- $myusername = mysqli_real_escape_string($db,$_POST['username']);
- $mypassword = mysqli_real_escape_string($db,$_POST['password']);
- $sql = "SELECT * FROM user WHERE Name = '$myusername' and Password = '$mypassword'";
- $result = mysqli_query($db,$sql);
- $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
- $active = $row['active'];
- $count = mysqli_num_rows($result);
- if($count == 1) {
- $_SESSION['login_user'] = $myusername;
- header("location: Welcome.php");
- }else {
- header("location: Login.html");
- }
- }
- ?>
- //Logout
- <?php
- session_start();
- if(session_destroy()) {
- header("Location: Login.html");
- }
- ?>
- //Welcome
- <html>
- <head>
- <title>Welcome </title>
- </head>
- <body>
- <h1>Welcome </h1>
- <h2><a href = "Logout.php">Sign Out</a></h2>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement