Guest User

Untitled

a guest
Aug 9th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $con=mysql_connect("localhost","test","test");
  4. mysql_select_db("employees");
  5. if(!$con)
  6. {
  7. die('No Connection:'.mysql_error());
  8. }
  9. else
  10. {
  11.  
  12. if($_POST['username']) {
  13. $username = $_POST['username'];
  14. $password = $_POST['password'];
  15. $query = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'");
  16. if($row = mysql_fetch_row($query))
  17. {
  18. echo('Welcome!');
  19.  
  20. }
  21. else
  22. {
  23. echo('Nope! You ain't a user here!!!');
  24. }
  25. }
  26. mysql_close($con);
  27. ?>
  28. <html>
  29. <head>
  30. <title>Employees authentication</title>
  31. </head>
  32. <body>
  33. <form method="POST" action="form.php">
  34. Username: <input type=text name="username"><br>
  35. Password: <input type=password name="password"><br>
  36. <input type=submit value="Login"><input type=reset>
  37. </form>
  38. </body>
  39. </html>
Add Comment
Please, Sign In to add comment