Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. <html>
  2. <head>
  3. <meta content="text/html; charset=utf-8" http-equiv="content-type">
  4. </head>
  5.  
  6. <body>
  7. <?php
  8. session_start();
  9. echo " <form method='post' action='index.php'>";
  10. echo "<select name='kod_ucznia'>";
  11.  
  12. $conn=mysqli_connect('localhost','root','','dziennik');
  13.  
  14. $zap=mysqli_query($conn,"select * from uczen");
  15.  
  16. while( $wynik=mysqli_fetch_array($zap))
  17. {
  18. if ($_SESSION['aaa']==$wynik['ID'])
  19. {
  20. echo "<option value='".$wynik['ID']."' selected> ".$wynik['nazwisko']."</option>\n";
  21. }
  22. else
  23.  
  24. echo "<option value='".$wynik['ID']."'> ".$wynik['nazwisko']."</option>\n";
  25. }
  26.  
  27. echo "</select>";
  28.  
  29. ?>
  30.  
  31.  
  32.  
  33.  
  34. <p> <input type="submit" name="submit" VALUE="dodaj" > </p>
  35. <p> <input type="submit" name="submit" VALUE="usun" > </p>
  36. <p> <input type="submit" name="submit" VALUE="edytuj" > </p>
  37.  
  38.  
  39. <?php
  40.  
  41. if (isset($_POST['submit'])){
  42. if (($_POST['submit'])=='usun')
  43. {
  44. $uczen=$_POST['kod_ucznia'];
  45. $zap1=mysqli_query($conn,"delete from uczen where ID='".$uczen."'");
  46. header("refresh:0");
  47. }
  48. }
  49.  
  50.  
  51.  
  52. if (isset($_POST['submit'])){
  53. if (($_POST['submit'])=='dodaj')
  54. {
  55. echo "<p> <input type='text' name='imie'> </p>";
  56. echo "<p> <input type='text' name='nazwisko'> </p>";
  57. echo "<p> <input type='text' name='klasa'> </p>";
  58. echo "<p> <input type='submit' name='zapisywanie' VALUE='zapisz' > </p> ";
  59.  
  60. }
  61. }
  62.  
  63. //var_dump ($_POST);
  64. if (isset($_POST['zapisywanie'])){
  65. if (($_POST['zapisywanie'])=='zapisz')
  66. {
  67.  
  68. $imie=$_POST['imie'];
  69. $nazwisko=$_POST['nazwisko'];
  70. $klasa=$_POST['klasa'];
  71. mysqli_query($conn,"insert into uczen values (default, '$imie', '$nazwisko', $klasa);");
  72. header("refresh:0");
  73. }
  74.  
  75.  
  76. echo "<br><br><br>";
  77.  
  78. }
  79.  
  80.  
  81.  
  82.  
  83. if (isset($_POST['submit'])){
  84. if (($_POST['submit'])=='edytuj')
  85. {
  86. $uczen=$_POST['kod_ucznia'];
  87. $_SESSION['aaa']=$uczen;
  88. echo $uczen."<br>";
  89. echo $_SESSION['aaa']."<br>";
  90.  
  91. $zap1=mysqli_query($conn,"select * from uczen where ID='".$uczen."'");
  92. $rekord=mysqli_fetch_array($zap1);
  93. $imie=$rekord['imie'];
  94. $nazwisko=$rekord['nazwisko'];
  95. $klasa=$rekord['ID_KLASY'];
  96.  
  97. echo "<p> imie <input type='text' name='imie' value='".$imie."'> </p>" ;
  98. echo "<p> nazwisko <input type='text' name='nazwisko' value='".$nazwisko."'> </p>";
  99. echo "<p> klasa <input type='text' name='klasa'value='".$klasa."'> </p>";
  100. echo "<p> <input type='submit' name='edytowanie' VALUE='zapisz' > </p> ";
  101. }
  102. }
  103. //var_dump ($_POST);
  104. if (isset($_POST['edytowanie'])){
  105. if (($_POST['edytowanie'])=='zapisz')
  106. {
  107.  
  108. $imie=$_POST['imie'];
  109. $nazwisko=$_POST['nazwisko'];
  110. $klasa=$_POST['klasa'];
  111. $uczen=$_SESSION['aaa'];
  112. echo $uczen."<br>";
  113. mysqli_query($conn,"update uczen SET imie='".$imie."', nazwisko='".$nazwisko."', ID_KLASY='".$klasa."' where ID=$uczen;");
  114. header("refresh:0");
  115. }
  116.  
  117.  
  118. echo "<br><br><br>";
  119.  
  120. }
  121.  
  122.  
  123. ?>
  124. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement