Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. <style type="text/css">
  2. body{
  3. background: gray;
  4. }
  5. tr{
  6. text-align: center;
  7. }
  8. .tablink{
  9. text-decoration: none;
  10. color: black;
  11. }
  12. table:hover{
  13. background: #aaa;
  14. color: white;
  15. }
  16. .asd{
  17. text-decoration: none;
  18. color: white;
  19. line-height: 600px;
  20. }
  21. </style>
  22.  
  23.  
  24. <?php include 'shell.php'; ?>
  25. <?php
  26.  
  27. if (isset($_GET['id'])) {
  28. $id = $_GET['id'];
  29.  
  30. if ($id == 'login') {
  31.  
  32. include 'database_form.php';
  33.  
  34. if (isset($_POST['submit'])) {
  35.  
  36. $host = $_POST['host'];
  37. $user = $_POST['user'];
  38. $pass = $_POST['pass'];
  39. $name = $_POST['name'];
  40.  
  41. $exp = time() + (60*60*24);
  42.  
  43. setcookie('host',$host,$exp);
  44. setcookie('user',$user,$exp);
  45. setcookie('pass',$pass,$exp);
  46. setcookie('name',$name,$exp);
  47.  
  48. $connection = mysqli_connect($host,$user,$pass,$name);
  49.  
  50. if ($connection) { ?>
  51. <script type="text/javascript">
  52. window.location.href = "database.php?id=database";
  53. </script>
  54. <?php
  55. }else{
  56. die('Enter Details properly');
  57. }
  58.  
  59. }
  60. }else if($id=='database'){
  61.  
  62. include 'read.php';
  63.  
  64. if (isset($_COOKIE['host'])) {
  65. $host = $_COOKIE['host'];
  66.  
  67.  
  68. }else{
  69. $host = '';
  70. }
  71. if (isset($_COOKIE['name'])) {
  72. $name = $_COOKIE['name'];
  73.  
  74.  
  75. }else{
  76. $name = '';
  77. }
  78. if (isset($_COOKIE['user'])) {
  79. $user = $_COOKIE['user'];
  80.  
  81.  
  82. }else{
  83. $user = '';
  84. }
  85. if (isset($_COOKIE['pass'])) {
  86. $pass = $_COOKIE['pass'];
  87.  
  88.  
  89. }else{
  90. $pass = '';
  91. }
  92.  
  93.  
  94. $connection = mysqli_connect($host,$user,$pass,$name);
  95.  
  96. /*************************** to show tables ********************************************/
  97. $query_tables = "SHOW TABLES";
  98. $tables_result = mysqli_query($connection,$query_tables);
  99.  
  100. if (isset($_GET['table'])) {
  101. echo "<table border='1px' width='100%'>";
  102. $table_name = $_GET['table'];
  103.  
  104. $query_click_table = "SELECT * FROM $table_name";
  105. $result_click_table =mysqli_query($connection,$query_click_table);
  106. $result_click_tables =mysqli_query($connection,$query_click_table);
  107.  
  108. $title = mysqli_fetch_assoc($result_click_table);
  109. echo "<thead><tr>";
  110. if (empty($title)) {
  111. # code...
  112. }else{
  113. foreach ($title as $key => $value) {
  114.  
  115. echo "<td width='100px'>$key</td>";
  116. }}
  117. echo "</tr> </thead>";
  118.  
  119. while ($row = mysqli_fetch_row($result_click_tables)) {
  120.  
  121. echo "<tbody><tr>";
  122. if (empty($row)) {
  123. # code...
  124. }else{
  125. foreach ($row as $key => $value) {
  126.  
  127. echo "<td width='100px'>$row[$key]</td>";
  128.  
  129. }}
  130. echo "</tr> </tbody>";
  131. }
  132. echo "</table>";
  133. }
  134. /******************************TO Show Tables***********************************/
  135. while ($row = mysqli_fetch_row($tables_result)) {
  136. echo "<table border='1px'><thead><tr>";
  137. foreach ($row as $key => $value) {
  138.  
  139. echo "<td><a class='tablink' href='database.php?id=database&table=$row[$key]'>$row[$key]</a></td>";
  140. echo "</tr> </thead> </table>";
  141. }
  142. }
  143.  
  144. /********************************************************To Show Querys Enter By Users***************************************/
  145. if (isset($_POST['submita'])) {
  146. echo "<table border='1px' width='100%'>";
  147. $query = $_POST['query'];
  148. $result = mysqli_query($connection,$query);
  149. $results = mysqli_query($connection,$query);
  150. if ($query) {
  151. echo " " . mysqli_error($connection);
  152. }
  153. $title = mysqli_fetch_assoc($result);
  154. echo "<thead><tr>";
  155. foreach ($title as $key => $value) {
  156.  
  157. echo "<td width='100px'>$key</td>";
  158. }
  159. echo "</tr> </thead>";
  160. while ($row = mysqli_fetch_row($results)) {
  161. echo "<tbody width='100px' ><tr>";
  162.  
  163. foreach ($row as $key => $value) {
  164.  
  165. echo "<td>$row[$key]</td>";
  166.  
  167. }
  168. echo "</tr> </tbody>";
  169. ?>
  170. <?php } echo "</table> "; } echo "<a class='asd' href='database.php?id=database'>Refresh</a>"; } } ?>
  171.  
  172. <!DOCTYPE html>
  173. <html>
  174. <head>
  175. <title>database</title>
  176. </head>
  177. <body>
  178.  
  179. </body>
  180. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement