Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.35 KB | None | 0 0
  1. <?php
  2. if (isset($_POST["idalunos"])) {
  3. $idalunos = $_POST["idalunos"];
  4. $erro = 1;
  5.  
  6. require_once("../../../../Connections/connections.php");
  7.  
  8. // Create a new DB connection
  9. $link = new_db_connection();
  10.  
  11. /* create a prepared statement */
  12. $stmt = mysqli_stmt_init($link);
  13. $link2 = new_db_connection();
  14.  
  15. /* create a prepared statement */
  16. $stmt2 = mysqli_stmt_init($link2);
  17.  
  18.  
  19. $query2 = "DELETE FROM encarregadoeducacao
  20. WHERE idencarregadoEducacao = ?
  21. ";
  22. $query = "SELECT pai_idpai, mae_idmae, autenticacao_idautenticacao, encarregadoEducacao_idencarregadoEducacao FROM alunos WHERE idalunos = ?";
  23.  
  24. if (mysqli_stmt_prepare($stmt, $query)) {
  25. mysqli_stmt_bind_param($stmt, 'i', $idalunos);
  26. /* execute the prepared statement */
  27. mysqli_stmt_execute($stmt);
  28.  
  29. /* bind result variables */
  30. mysqli_stmt_bind_result($stmt, $pai, $mae, $aut, $enc);
  31.  
  32. /* fetch values */
  33. while (mysqli_stmt_fetch($stmt)) {
  34.  
  35.  
  36.  
  37. if (mysqli_stmt_prepare($stmt2, $query2)) {
  38.  
  39. mysqli_stmt_bind_param($stmt2, 'i',$enc );
  40.  
  41. /* execute the prepared statement */
  42. if (!mysqli_stmt_execute($stmt2)) {
  43.  
  44. $erro = 2;
  45. //header("Location: index.php?msgDelete= $erro#mensagem");
  46. } else {
  47. echo "aquii3i";
  48.  
  49. $link3 = new_db_connection();
  50.  
  51. /* create a prepared statement */
  52. $stmt3 = mysqli_stmt_init($link3);
  53. $query3 = "DELETE FROM pai
  54. WHERE idpai = ?
  55. ";
  56.  
  57. if (mysqli_stmt_prepare($stmt3, $query3)) {
  58.  
  59. mysqli_stmt_bind_param($stmt3, 'i',$pai );
  60.  
  61. /* execute the prepared statement */
  62. if (!mysqli_stmt_execute($stmt3)) {
  63.  
  64. $erro = 2;
  65. //header("Location: index.php?msgDelete= $erro#mensagem");
  66. } else {
  67. $link4 = new_db_connection();
  68.  
  69. /* create a prepared statement */
  70. $stmt4 = mysqli_stmt_init($link4);
  71. $query4 = "DELETE FROM mae
  72. WHERE idmae = ?
  73. ";
  74.  
  75. if (mysqli_stmt_prepare($stmt4, $query4)) {
  76.  
  77. mysqli_stmt_bind_param($stmt4, 'i',$mae );
  78.  
  79. /* execute the prepared statement */
  80. if (!mysqli_stmt_execute($stmt4)) {
  81.  
  82. $erro = 2;
  83. //header("Location: index.php?msgDelete= $erro#mensagem");
  84. } else {
  85. $link5 = new_db_connection();
  86.  
  87. /* create a prepared statement */
  88. $stmt5 = mysqli_stmt_init($link5);
  89. $query5 = "DELETE FROM autenticacao
  90. WHERE idautenticacao = ?
  91. ";
  92.  
  93. if (mysqli_stmt_prepare($stmt5, $query5)) {
  94.  
  95. mysqli_stmt_bind_param($stmt5, 'i',$aut );
  96.  
  97. /* execute the prepared statement */
  98. if (!mysqli_stmt_execute($stmt5)) {
  99.  
  100. $erro = 2;
  101. //header("Location: index.php?msgDelete= $erro#mensagem");
  102. } else {
  103.  
  104. }
  105.  
  106. /* close statement */
  107. mysqli_stmt_close($stmt5);
  108. } else {
  109. echo "Error: " . mysqli_error($link5);
  110. }
  111.  
  112. /* close connection */
  113. mysqli_close($link5);
  114.  
  115. // header("Location: index.php?msgDelete= $erro#mensagem");
  116. }
  117.  
  118. /* close statement */
  119. mysqli_stmt_close($stmt4);
  120. } else {
  121. echo "Error: " . mysqli_error($link4);
  122. }
  123.  
  124. /* close connection */
  125. mysqli_close($link4);
  126.  
  127. // header("Location: index.php?msgDelete= $erro#mensagem");
  128. }
  129.  
  130. /* close statement */
  131. mysqli_stmt_close($stmt3);
  132. } else {
  133. echo "Error: " . mysqli_error($link3);
  134. }
  135.  
  136. /* close connection */
  137. mysqli_close($link3);
  138.  
  139. // header("Location: index.php?msgDelete= $erro#mensagem");
  140.  
  141. }
  142.  
  143. /* close statement */
  144. mysqli_stmt_close($stmt2);
  145. } else {
  146. echo "Error: " . mysqli_error($link2);
  147. }
  148.  
  149. /* close connection */
  150. mysqli_close($link2);
  151.  
  152. // header("Location: index.php?msgDelete= $erro#mensagem");
  153.  
  154. }
  155.  
  156. }else{
  157.  
  158. }
  159. mysqli_stmt_close($stmt);
  160.  
  161. }else{
  162.  
  163. }
  164.  
  165. mysqli_close($link);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement