Advertisement
Guest User

Untitled

a guest
Jan 15th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. <html>
  2. <head>
  3. <link href = "style.css" rel = "stylesheet" type = "text/css"
  4.  
  5. </head>
  6.  
  7. <body>
  8. <h1>Forma za unos korisnika</h1>
  9.  
  10. <form action="" method = "POST">
  11. Ime: <input type = "text" name = "ime"><br>
  12. Prezime: <input type = "text" name = "prezime"><br>
  13. Tip: <select name = "tip">
  14. <option>Admin</option>
  15. <option>Moderator</option>
  16. <option>Korisnik</option>
  17. </select><br>
  18. <input type = "submit" name = "dodaj" value = "Dodaj korisnika">
  19. <input type = "submit" name = "upit" value = "Prosledi upit"><br>
  20. ID: <input type = "text" name = "brisi"><input type = "submit" name = "ukloni" value = "Ukloni korisnika"><br>
  21. <input type = "submit" name = "tabela" value = "Prikazi tabelu">
  22. </form>
  23.  
  24.  
  25. </body>
  26.  
  27. <?php
  28.  
  29. $localhost = "localhost";
  30. $username = "root";
  31. $password = "";
  32.  
  33. $konekcija = new mysqli($localhost,$username,$password);
  34.  
  35. $baza = "CREATE DATABASE PraviKorisnici";
  36. //$konekcija->query($baza) or die($konekcija->error);
  37.  
  38. mysqli_select_db($konekcija, "PraviKorisnici");
  39.  
  40.  
  41.  
  42. $tabela = "CREATE TABLE Unos (
  43. ID INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  44. Ime VARCHAR(15),
  45. Prezime VARCHAR(15),
  46. Tip VARCHAR(15)
  47. )";
  48.  
  49.  
  50.  
  51. //$konekcija->query($tabela) or die($konekcija->error);
  52.  
  53.  
  54.  
  55. if(isset($_POST["dodaj"])){
  56.  
  57. $ime = $_POST["ime"];
  58. $prezime = $_POST["prezime"];
  59. $tip = $_POST["tip"];
  60.  
  61.  
  62.  
  63. $unos = "INSERT INTO Unos (Ime,Prezime,Tip) VALUES ('$ime','$prezime','$tip')";
  64. $konekcija->query($unos) or die($konekcija->error);
  65.  
  66.  
  67. }
  68.  
  69. if(isset($_POST["upit"])){
  70.  
  71. //$upit = "SELECT PraviKorisnici.Unos.ID, PraviKorisnici.Unos.Ime, PraviKorisnici.Unos.Prezime, PraviKorisnici.Unos.Tip, DrugiKorisnici.DrugiUnos.Plata, DrugiKorisnici.DrugiUnos.Adresa, DrugiKorisnici.DrugiUnos.Broj_telefona FROM PraviKorisnici.Unos INNER JOIN DrugiKorisnici.DrugiUnos ON Unos.ID = '3' AND DrugiUnos.ID = '3' ";
  72. $upit = "SELECT * FROM PraviKorisnici.Unos,DrugiKorisnici.DrugiUnos WHERE Unos.ID = '2' AND DrugiUnos.ID = '2' ";
  73. $rezultat = $konekcija->query($upit) or die($konekcija->error);
  74.  
  75.  
  76. $niz = $rezultat->fetch_all();
  77.  
  78.  
  79. echo "<table align = 'center' border = 1>";
  80.  
  81. echo"<tr>";
  82. echo"<td class = 'class'>ID</td>";
  83. echo"<td class = 'class'>Ime</td>";
  84. echo"<td class = 'class'>Prezime</td>";
  85. echo"<td class = 'class'>Tip</td>";
  86. echo"<td class = 'class'>Plata</td>";
  87. echo"<td class = 'class'>Adresa</td>";
  88. echo"<td class = 'class'>Broj_telefona</td>";
  89. echo"</tr>";
  90.  
  91. foreach($niz as $row){
  92. //echo "ID: " . $row[0]. " Ime: " . $row[1]. " Prezime: " . $row[2]. " Tip: " . $row[3] . "<br>";
  93. echo"<tr>";
  94. echo"<td>".$row[0]."</td>";
  95. echo"<td>".$row[1]."</td>";
  96. echo"<td>".$row[2]."</td>";
  97. echo"<td>".$row[3]."</td>";
  98. echo"<td>".$row[5]."</td>";
  99. echo"<td>".$row[6]."</td>";
  100. echo"<td>".$row[7]."</td>";
  101. echo"</tr>";
  102. }
  103.  
  104. echo "</table>";
  105.  
  106. }
  107. if(isset($_POST["ukloni"])){
  108.  
  109. $brisi = $_POST["brisi"];
  110. $uklon = "DELETE FROM Unos WHERE Unos.ID = '$brisi'";
  111. $konekcija->query($uklon) or die($konekcija->error);
  112.  
  113. }
  114.  
  115. if(isset($_POST["tabela"])){
  116.  
  117. echo "<table align = 'center' border = 1>";
  118. echo"<tr>";
  119. echo"<td class = 'class'>ID</td>";
  120. echo"<td class = 'class'>Ime</td>";
  121. echo"<td class = 'class'>Prezime</td>";
  122. echo"<td class = 'class'>Tip</td>";
  123. echo"</tr>";
  124.  
  125.  
  126. $upit1 = "SELECT * FROM Unos";
  127. $rez = $konekcija->query($upit1);
  128. $niz1 = $rez->fetch_all();
  129.  
  130. foreach($niz1 as $row1){
  131. echo "<tr>";
  132. echo "<td>".$row1[0]."</td>";
  133. echo "<td>".$row1[1]."</td>";
  134. echo "<td>".$row1[2]."</td>";
  135. echo "<td>".$row1[3]."</td>";
  136. echo "</tr>";
  137. }
  138. echo "</table>";
  139.  
  140. }
  141.  
  142.  
  143. ?>
  144.  
  145. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement