Advertisement
polectron

Untitled

Jan 8th, 2019
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. </head>
  5. <body>
  6. <?php
  7.  
  8. $MYSQLSERVER = "localhost";
  9. $USER = "root";
  10. $PASSWORD = "";
  11. $DATABASE = "registro";
  12.  
  13. $mysqli = new mysqli($MYSQLSERVER, $USER, $PASSWORD, $DATABASE);
  14.  
  15. $mysqli->set_charset("utf8");
  16.  
  17. if ($mysqli->connect_errno) {
  18. echo "ERROR DB";
  19. die('Error de conexión: ' . $mysqli->connect_error);
  20. exit;
  21. }
  22.  
  23. if(isset($_REQUEST["player_name"])){
  24. $stmt = $mysqli->prepare("INSERT INTO registro (player_name, player_id, type, info) VALUES (?,?,?,?)");
  25. $stmt->bind_param('ssss',$_REQUEST["player_name"],$_REQUEST["player_id"],$_REQUEST["type"],$_REQUEST["info"]);
  26.  
  27. print_r($_REQUEST);
  28.  
  29. if (!$stmt->execute()) {
  30. echo "ERROR SQL";
  31. exit;
  32. }
  33.  
  34. $stmt->close();
  35. }else{
  36.  
  37. if(isset($_REQUEST["filter_type"])){
  38. $stmt = $mysqli->prepare("SELECT * FROM registro WHERE type = ?");
  39. $stmt->bind_param('s', $_REQUEST["filter_type"]);
  40. }else if(isset($_REQUEST["filter_id"])){
  41. $stmt = $mysqli->prepare("SELECT * FROM registro WHERE player_id = ?");
  42. $stmt->bind_param('s', $_REQUEST["filter_id"]);
  43. }else{
  44. $stmt = $mysqli->prepare("SELECT * FROM registro");
  45. }
  46.  
  47. if (!$stmt->execute()) {
  48. echo "ERROR SQL";
  49. exit;
  50. }
  51.  
  52. $result = $stmt->get_result();
  53.  
  54. ?>
  55.  
  56. <a href="/registro.php"><h2>Inicio</h2></a>
  57.  
  58. <table border=1>
  59. <thead>
  60. <tr>
  61. <th>Player ID</th>
  62. <th>Player Name</th>
  63. <th>Tipo</th>
  64. <th>Fecha</th>
  65. <th>Info</th>
  66. </tr>
  67. </thead>
  68. <tbody>
  69. <?php
  70. while($row = $result->fetch_assoc())
  71. {
  72. ?>
  73. <tr>
  74. <td><a href="registro.php?filter_id=<?php echo $row["player_id"];?>"><?php echo $row["player_id"];?></a></td>
  75. <td><?php echo $row["player_name"];?></td>
  76. <td><a href="registro.php?filter_type=<?php echo $row["type"];?>"><?php echo $row["type"];?></a></td>
  77. <td><?php echo $row["date"];?></td>
  78. <td><?php echo $row["info"];?></td>
  79. </tr>
  80. <?php
  81. }
  82. ?>
  83. </tbody>
  84. </table>
  85.  
  86. <?php
  87. $stmt->close();
  88. }
  89.  
  90. $mysqli->close();
  91.  
  92. ?>
  93. </body>
  94. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement