Advertisement
Guest User

Untitled

a guest
Mar 4th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <html>
  2. <body>
  3. <?php
  4. if(isset($_POST['login']))
  5. {
  6. $username = $_POST['username'];
  7. $password = $_POST['password'];
  8. $con = mysqli_connect('localhost','root','your_mysql_password','sample');
  9. $result = mysqli_query($con, "SELECT * FROM `users` WHERE username='$username' AND password='$password'");
  10. if(mysqli_num_rows($result) == 0)
  11. echo 'Invalid username or password';
  12. else
  13. echo '<h1>Logged in</h1><p>This is text that should only be displayed when logged in with valid credentials.</p>';
  14. }
  15. else
  16. {
  17. ?>
  18. <form action="" method="post">
  19. Username: <input type="text" name="username"/><br />
  20. Password: <input type="password" name="password"/><br />
  21. <input type="submit" name="login" value="Login"/>
  22. </form>
  23. <?php
  24. }
  25. ?>
  26. </body>
  27. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement