No Description

usersTable.php 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <!-- Users table Page for TPMG -->
  2. <!-- http://https://ada.uprrp.edu/~pablo.puig1/TPMG/userTable.php -->
  3. <!--Page background color-->
  4. <body style="background-color:#6cd1f4">
  5. <!--Navigation Bar-->
  6. <!doctype html>
  7. <html lang="en">
  8. <head>
  9. <meta charset="utf-8">
  10. <meta name="viewport" content="width=device-width, initial-scale=1">
  11. <title>TPMG admin</title>
  12. <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
  13. </head>
  14. <nav class="navbar navbar-expand-lg bg-light">
  15. <div class="container-fluid">
  16. <!-- <a class="navbar-brand" href="/">TPMG</a> -->
  17. <img src="LogoSidename.png" alt="logo" width="200"/>
  18. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  19. <span class="navbar-toggler-icon"></span>
  20. </button>
  21. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  22. <ul class="navbar-nav me-auto mb-2 mb-lg-0">
  23. <li class="nav-item">
  24. <a href="TPMG.php" class="nav-link active" aria-current="page">Home</a>
  25. </li>
  26. <li class="nav-item">
  27. <a href="usersTable.php" class="nav-link">Users</a>
  28. </li>
  29. <li class="nav-item">
  30. <a href="eventsTable.php" class="nav-link">Events</a>
  31. </li>
  32. <li class="nav-item">
  33. <a href="about.php" class="nav-link">About</a>
  34. </li>
  35. </ul>
  36. </div>
  37. </div>
  38. </nav>
  39. <?PHP
  40. //---------------
  41. // Connection to server and database
  42. //---------------
  43. $host = "localhost";
  44. $basedatos = "techos";
  45. $user = "pablo.puig1";
  46. $passw = "9NA3kSExI2fGE6eV";
  47. try{
  48. $connection = mysqli_connect($host, $user, $passw, $basedatos) or $error = 1;
  49. }
  50. catch(Exception $ex){
  51. print("Error connecting to database: ". $ex->getMessage()) and die();
  52. }
  53. ?>
  54. <!-- Add User Panel -->
  55. <div class="container-fluid px-1 py-5 mx-auto">
  56. <div class="row d-flex justify-content-center">
  57. <div class="col-xl-7 col-lg-8 col-md-9 col-11 text-center">
  58. <div class="card">
  59. <h5 class="text-left mb-4">Enter Information to Add User:</h5>
  60. <form class="form-card" method="post" action="./addUser.php">
  61. <div class="row justify-content-between text-left">
  62. <div class="form-group col-sm-6 flex-column d-flex"> <label class="form-control-label px-3">First and Last name<span class="text-danger"> *</span></label> <input type="text" id="username" name="username" placeholder="" onblur="validate(1)" > </div>
  63. <div class="form-group col-sm-6 flex-column d-flex"> <label class="form-control-label px-3">Account type<span class="text-danger"> *</span></label> <input type="text" id="ACC" name="ACC" placeholder="" onblur="validate(2)" > </div>
  64. </div>
  65. <br>
  66. <div class="row justify-content-between text-left">
  67. <div class="form-group col-sm-6 flex-column d-flex"> <label class="form-control-label px-3">Email<span class="text-danger"> *</span></label><input type="text" id="email" name="email" placeholder="" onblur="validate(3)"> </div>
  68. <div class="form-group col-sm-6 flex-column d-flex"> <label class="form-control-label px-3">Phone number<span class="text-danger"> *</span></label> <input type="text" id="phone" name="phone" placeholder="" onblur="validate(4)"> </div>
  69. </div>
  70. <br>
  71. <div class="row justify-content-end">
  72. <div class="form-group col-mb-4"> <button type="submit" class="btn btn-primary" value="Add">Add</button> </div>
  73. </div>
  74. </form>
  75. </div>
  76. </div>
  77. </div>
  78. <br>
  79. <!-- Delete User Panel -->
  80. <div class="row d-flex justify-content-center">
  81. <div class="col-xl-7 col-lg-8 col-md-9 col-11 text-center">
  82. <div class="card">
  83. <h5 class="text-left mb-4">Enter User-ID to delete:</h5>
  84. <form class="form-card" method="post" action="./deleteUser.php">
  85. <div class="row justify-content-between text-left">
  86. <div class="row d-flex justify-content-center"> <label class="form-control-label px-3">User-ID<span class="text-danger"> *</span></label> <input type="int" id="UID" name="UID" placeholder="" onblur="validate(1)" style="width: 275px"> </div>
  87. </div>
  88. <br>
  89. <div class="row justify-content-end">
  90. <div class="form-group col-mb-4"> <button type="submit" class="btn btn-primary" value="Delete">Delete</button> </div>
  91. </div>
  92. </form>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <!-- Table -->
  98. <style>
  99. table{
  100. border-collapse: collapse;
  101. width: 75%
  102. }
  103. th, td {
  104. padding: 8px;
  105. text-align: left;
  106. border-bottom: 1px solid black;
  107. }
  108. rt {
  109. background-color: #D6EEEE
  110. }
  111. </style>
  112. <table style="background-color: #ffffff;margin-left:auto;margin-right:auto">
  113. <?PHP
  114. //---------------
  115. // Table that displays Users in the server
  116. //---------------
  117. $querySeeUsers= "SELECT * from users";
  118. $stmtSee=mysqli_prepare($connection, $querySeeUsers);
  119. mysqli_stmt_execute($stmtSee);
  120. mysqli_stmt_bind_result($stmtSee, $uid, $acc_type, $name, $email, $phone);
  121. //Making table headers
  122. print "<tr>";
  123. print "<td>";
  124. print "User-ID"; //User-ID
  125. print "</td>";
  126. print "<td>";
  127. print "Account Type"; //Account type
  128. print "</td>";
  129. print "<td>";
  130. print "Name"; //Name
  131. print "</td>";
  132. print "<td>";
  133. print "Email"; //Email
  134. print "</td>";
  135. print "<td>";
  136. print "Phone"; //Phone
  137. print "</td>";
  138. print "</tr>";
  139. //iterating line by line
  140. while(mysqli_stmt_fetch($stmtSee)){
  141. print "<tr>";
  142. print "<td>";
  143. print $uid; //printing UID
  144. print "</td>";
  145. print "<td>";
  146. print $acc_type; //printing account type
  147. print "</td>";
  148. print "<td>";
  149. print $name; //printing name
  150. print "</td>";
  151. print "<td>";
  152. print $email; //printing email
  153. print "</td>";
  154. print "<td>";
  155. print $phone; //printing phone
  156. print "</td>";
  157. print "\n";
  158. }
  159. ?>
  160. </table>
  161. <br/>
  162. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
  163. <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js" integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3" crossorigin="anonymous"></script>
  164. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V" crossorigin="anonymous"></script>
  165. </body>
  166. </html>