Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <? session_start(); ?>
- <html>
- <head>
- <title>Login</title></head>
- <body>
- <?php
- include('config.php');
- if ($_GET['action'] == "logout")
- {
- session_unset();
- session_destroy();
- if (!isset($_SESSION['login']))
- {
- echo 'Succesfully logged out';
- }
- }
- else
- {
- if (isset($_POST['Username']))
- {
- $Username = mysql_real_escape_string($_POST['Username']);
- $Password = mysql_real_escape_string($_POST['Username']);
- $db = mysql_select_db("login", $connect);
- $query = mysql_query("SELECT * FROM users WHERE Username='" . $Username . "' and Password='" . $Password);
- $check = mysql_num_rows($query);
- if ($check > 0)
- {
- echo 'Succesfully logged in';
- $_SESSION['login'] = $Username;
- }
- else
- {
- echo 'Wrong Username/Password';
- }
- }
- if (isset($_SESSION['login']))
- {
- echo 'Welcome, ' .$_SESSION['login'];
- echo '<br /><a href="index.php?action=logout">Logout</a>';
- }
- else
- {
- echo '<form action="' .$_SERVER['PHP_SELF']. '" method="POST">';
- echo 'Username: <input type="text" name="Username" /><br />';
- echo 'Password: <input type="text" name="Password" /><br />';
- echo '<input type="submit" value="Log in" />';
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement