Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Painel de controlo</title>
- </head>
- <style type="text/css">
- p{
- text-align: center;
- }
- </style>
- <body style="background-color: blue;">
- <?php
- $turnbd = new mysqli('localhost','usr21','dacic2019','usr21');
- $numaluno=$tnick=$ttempo=$msg='';
- if ($turnbd->connect_error) {
- die('Erro na ligação : ('. $turnbd->connect_errno .') '. $turnbd->connect_error);
- }
- //Listagem
- if(isset($_POST['listar'])){
- // Verificar se o registo existe
- $query = "SELECT numaluno,nickname,tempo FROM a11680_resultados WHERE numaluno=?";
- $statement = $turnbd->prepare($query);
- $statement->bind_param('i',$_POST["listar"]);
- $statement->execute();
- $statement->bind_result($tnumaluno,$tnick,$ttempo);
- $statement->fetch();
- $statement->close();
- }
- //Alterar
- if(isset($_POST['alterar'])){
- if($_POST["listar"]=="-1" || $_POST["nick"]=="" || $_POST["tempo"]=="" ){
- $msg="<div class='alert'>Dados de jogo errados!</div>";
- }
- else{
- $query = "UPDATE a11680_resultados SET nickname=?,tempo=? WHERE numaluno=?";
- $statement = $turnbd->prepare($query);
- $statement->bind_param('ssi', $_POST["nick"],$_POST["tempo"],$_POST["listar"]);
- if ($statement->execute() && $statement->affected_rows>0){
- $msg= "<div class='ok'>Foi atualizado jogo!</div>";
- }
- else{
- $msg= "<div class='alert'>Erro!</div>";
- }
- $statement->close();
- }
- }
- //Apagar
- if(isset($_POST['apagar'])){
- $query = "DELETE FROM a11680_resultados WHERE numaluno=?";
- $statement = $turnbd->prepare($query);
- $statement->bind_param('i',$_POST["listar"]);
- if ($statement->execute() && $statement->affected_rows>0) {
- $msg= "<div class='ok'>Registo eliminado!</div>";
- }
- else{
- echo "<div class='alert'><h1>NΓ£o foi encontrado o registo!!</h1></div>";
- }
- }
- ?>
- <div class="" style="border: 2px solid white; width: 50%; background-color:green; color: white; margin: auto;">
- <h1 style="text-align: center;">Painel de Controlo</h1>
- <form class="" action="" method="post" name="lista">
- <p><h3 style="text-align:center;"><label>Numero:</label></h3></p>
- <input type="hidden" name="lista" value="<?php echo $tnumaluno; ?>">
- <p><select name="listar" onChange="document.lista.submit()" style="text-align: center;">
- <option value="-1">Seleccione o numero</option>
- <?php
- $query = "SELECT numaluno from a11680_resultados";
- $statement = $turnbd->query($query);
- while ($row1=$statement->fetch_array()) {
- if( $row1["numaluno"]==$tnumaluno){
- $d='selected="selected"';
- }
- else{
- $d='';
- }
- echo '<option value="'. $row1["numaluno"] .'" ' . $d .' >'. $row1["numaluno"] .'</option>';
- }
- $statement->free();
- ?>
- </select></p>
- <p><?php echo $msg; ?></p>
- <p style="text-align:center;"><h3 style="text-align:center;">Nickname:</h3></p>
- <p style="text-align:center;"><input style="width: 150px; height: 20px; font-size: 15px; text-align: center;" type="text" name="nick" value="<?php echo $tnick; ?>" ></p>
- <p style="text-align:center;"><h3 style="text-align:center;">Tempo:</h3></p>
- <p style="text-align:center;"><input style="width: 150px; height: 20px; font-size: 15px; text-align: center;" type="text" name="tempo" id="tempo" value="<?php echo $ttempo; ?>"></p>
- <p style="text-align:center;"><input style="border-radius: 0px; width: 200px; height:65px; font-size: 20px;" class="" name="alterar" type="submit" value="Alterar Resultados"></p><br>
- <p style="text-align:center;"><input style="border-radius: 0px; width: 200px; height:65px; font-size: 20px;" class="" name="apagar" type="submit" value="Apagar Resultados"></p>
- </form>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment