drunkspinda02

Untitled

Mar 26th, 2019
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Painel de controlo</title>
  5. </head>
  6. <style type="text/css">
  7. p{
  8. text-align: center;
  9. }
  10. </style>
  11. <body style="background-color: blue;">
  12. <?php
  13.  
  14. $turnbd = new mysqli('localhost','usr21','dacic2019','usr21');
  15.  
  16. $numaluno=$tnick=$ttempo=$msg='';
  17.  
  18. if ($turnbd->connect_error) {
  19. die('Erro na ligação : ('. $turnbd->connect_errno .') '. $turnbd->connect_error);
  20. }
  21.  
  22. //Listagem
  23.  
  24. if(isset($_POST['listar'])){
  25.  
  26. // Verificar se o registo existe
  27. $query = "SELECT numaluno,nickname,tempo FROM a11680_resultados WHERE numaluno=?";
  28. $statement = $turnbd->prepare($query);
  29. $statement->bind_param('i',$_POST["listar"]);
  30. $statement->execute();
  31. $statement->bind_result($tnumaluno,$tnick,$ttempo);
  32. $statement->fetch();
  33. $statement->close();
  34. }
  35.  
  36. //Alterar
  37.  
  38. if(isset($_POST['alterar'])){
  39.  
  40. if($_POST["listar"]=="-1" || $_POST["nick"]=="" || $_POST["tempo"]=="" ){
  41. $msg="<div class='alert'>Dados de jogo errados!</div>";
  42. }
  43. else{
  44.  
  45.  
  46. $query = "UPDATE a11680_resultados SET nickname=?,tempo=? WHERE numaluno=?";
  47. $statement = $turnbd->prepare($query);
  48. $statement->bind_param('ssi', $_POST["nick"],$_POST["tempo"],$_POST["listar"]);
  49. if ($statement->execute() && $statement->affected_rows>0){
  50. $msg= "<div class='ok'>Foi atualizado jogo!</div>";
  51. }
  52. else{
  53. $msg= "<div class='alert'>Erro!</div>";
  54. }
  55. $statement->close();
  56. }
  57.  
  58. }
  59.  
  60. //Apagar
  61.  
  62. if(isset($_POST['apagar'])){
  63. $query = "DELETE FROM a11680_resultados WHERE numaluno=?";
  64. $statement = $turnbd->prepare($query);
  65. $statement->bind_param('i',$_POST["listar"]);
  66.  
  67. if ($statement->execute() && $statement->affected_rows>0) {
  68. $msg= "<div class='ok'>Registo eliminado!</div>";
  69. }
  70. else{
  71. echo "<div class='alert'><h1>NΓ£o foi encontrado o registo!!</h1></div>";
  72. }
  73. }
  74.  
  75.  
  76. ?>
  77. <div class="" style="border: 2px solid white; width: 50%; background-color:green; color: white; margin: auto;">
  78. <h1 style="text-align: center;">Painel de Controlo</h1>
  79. <form class="" action="" method="post" name="lista">
  80. <p><h3 style="text-align:center;"><label>Numero:</label></h3></p>
  81. <input type="hidden" name="lista" value="<?php echo $tnumaluno; ?>">
  82. <p><select name="listar" onChange="document.lista.submit()" style="text-align: center;">
  83. <option value="-1">Seleccione o numero</option>
  84. <?php
  85. $query = "SELECT numaluno from a11680_resultados";
  86. $statement = $turnbd->query($query);
  87. while ($row1=$statement->fetch_array()) {
  88. if( $row1["numaluno"]==$tnumaluno){
  89. $d='selected="selected"';
  90. }
  91. else{
  92. $d='';
  93.  
  94. }
  95. echo '<option value="'. $row1["numaluno"] .'" ' . $d .' >'. $row1["numaluno"] .'</option>';
  96. }
  97.  
  98. $statement->free();
  99. ?>
  100. </select></p>
  101. <p><?php echo $msg; ?></p>
  102. <p style="text-align:center;"><h3 style="text-align:center;">Nickname:</h3></p>
  103. <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>
  104. <p style="text-align:center;"><h3 style="text-align:center;">Tempo:</h3></p>
  105. <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>
  106. <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>
  107. <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>
  108. </form>
  109. </div>
  110. </body>
  111. </html>
Add Comment
Please, Sign In to add comment