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{
- $sql = "SELECT * FROM registro";
- $stmt = $mysqli->prepare($sql);
- if (!$stmt->execute()) {
- echo "ERROR SQL";
- exit;
- }
- $result = $stmt->get_result();
- ?>
- <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><?php echo $row["player_id"];?></td>
- <td><?php echo $row["player_name"];?></td>
- <td><?php echo $row["type"];?></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