Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- </head>
- <body>
- <?php
- $MYSQLSERVER = "localhost";
- $USER = "root";
- $PASSWORD = "";
- $DATABASE = "registro";
- $mysqli = new mysqli($MYSQLSERVER, $USER, $PASSWORD, $DATABASE);
- $mysqli->set_charset("utf8");
- if ($mysqli->connect_errno) {
- echo "ERROR DB";
- die('Error de conexión: ' . $mysqli->connect_error);
- exit;
- }
- if(isset($_REQUEST["player_name"])){
- $stmt = $mysqli->prepare("INSERT INTO registro (player_name, player_id, type, info) VALUES (?,?,?,?)");
- $stmt->bind_param('ssss',$_REQUEST["player_name"],$_REQUEST["player_id"],$_REQUEST["type"],$_REQUEST["info"]);
- print_r($_REQUEST);
- if (!$stmt->execute()) {
- echo "ERROR SQL";
- exit;
- }
- $stmt->close();
- }else{
- if(isset($_REQUEST["filter_type"])){
- $stmt = $mysqli->prepare("SELECT * FROM registro WHERE type = ?");
- $stmt->bind_param('s', $_REQUEST["filter_type"]);
- }else if(isset($_REQUEST["filter_id"])){
- $stmt = $mysqli->prepare("SELECT * FROM registro WHERE player_id = ?");
- $stmt->bind_param('s', $_REQUEST["filter_id"]);
- }else{
- $stmt = $mysqli->prepare("SELECT * FROM registro");
- }
- if (!$stmt->execute()) {
- echo "ERROR SQL";
- exit;
- }
- $result = $stmt->get_result();
- ?>
- <a href="/registro.php"><h2>Inicio</h2></a>
- <table border=1>
- <thead>
- <tr>
- <th>Player ID</th>
- <th>Player Name</th>
- <th>Tipo</th>
- <th>Fecha</th>
- <th>Info</th>
- </tr>
- </thead>
- <tbody>
- <?php
- while($row = $result->fetch_assoc())
- {
- ?>
- <tr>
- <td><a href="registro.php?filter_id=<?php echo $row["player_id"];?>"><?php echo $row["player_id"];?></a></td>
- <td><?php echo $row["player_name"];?></td>
- <td><a href="registro.php?filter_type=<?php echo $row["type"];?>"><?php echo $row["type"];?></a></td>
- <td><?php echo $row["date"];?></td>
- <td><?php echo $row["info"];?></td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table>
- <?php
- $stmt->close();
- }
- $mysqli->close();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement