Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require('connect.php');
- if(isset($_POST['username']) and isset($_POST['password'])) {
- $username=$_POST['username'];
- $password=$_POST['password'];
- $query="SELECT * FROM 'user' WHERE username='
- $username' and password='$password'";
- $result=mysql_query($connection,$query) or die (mysqli_error ($connection));
- $count= mysqli_nm_row($result);
- if ($count==1) {
- $_SESSION['username'] = $username;
- } else {
- $fmsg= "Invalid Login Credentials.";
- }
- }
- if(isset($_SESSION['username'])) {
- echo "Hello" . $username ."";
- echo "Welcome to the Landing Page!";
- session_destroy();
- echo "<a href= 'logout.php'> Logout</a>";
- }
- ?>
- <html>
- <head>
- <title>User Login Using PHP & MySQL</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
- <link rel="stylesheet" href="styles.css">
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container">
- <form class="form-signin" method="POST">
- <?php if(isset($fmsg)) {?><div class="alert
- alert-danger" role="alert"><?php echo $fmsg;?>
- </div><?php }?>
- <h2 class="form-signin-heading">Please Login</h2>
- <div class="input-group">
- <span class="input-group-addon" id="basic-addon1">
- @</span>
- <input type="text" name="username" class=
- "form-control" placeholder= "Username" required>
- </div>
- <label for="inputPassword" class="sr-only">
- </label>
- <input type="password" name="password" id=
- "inputPassword" class="form-control"
- placeholder="Password" required>
- <button class="btn btn-lg btn-primary btn-block" type="submit">Login</button>
- <a class="btn btn-lg btn-primary btn-block" href="register.php">Register</a>
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement