Advertisement
Guest User

slesh

a guest
Jan 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Welcome</title>
  6. <style>
  7. h1, h2, h3{
  8. color: coral;
  9. text-align: center;
  10. }
  11.  
  12. </style>
  13. </head>
  14. <body>
  15. <?php
  16. //read user inputs from login form
  17. $name=$_POST["name"];
  18. echo "<h1>Welcome $name</h1>";
  19. $password=$_POST["password"];
  20. //declare database variables
  21. $dbserver="localhost:3307";
  22. $dbuser="root";
  23. $dbpassword="";
  24. $dbname="sbdb2019";
  25. //create connection
  26. $conn = new mysqli($dbserver,$dbuser,$dbpassword,$dbname);
  27. //check connection successful
  28. if($conn->connect_error==true){
  29. echo "connection failed".$conn->connect_error;
  30. }else{
  31. echo "<h2>Connection Successful</h2>";
  32. }
  33. //create sql to check user and password
  34. $sql="SELECT * FROM CUSTOMER WHERE name='".$name."' and password='".$password."'";
  35. //execute sql and assign to result
  36. $result = $conn->query($sql);
  37. //check whether result has any rows
  38. if($result->num_rows>0){
  39.  
  40. }else{
  41. die("<h3>You are not authorised to access this information</h3>");
  42. }
  43.  
  44. ?>
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement