Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <link href = "style.css" rel = "stylesheet" type = "text/css"
- </head>
- <body>
- <h1>Forma za unos korisnika</h1>
- <form action="" method = "POST">
- Ime: <input type = "text" name = "ime"><br>
- Prezime: <input type = "text" name = "prezime"><br>
- Tip: <select name = "tip">
- <option>Admin</option>
- <option>Moderator</option>
- <option>Korisnik</option>
- </select><br>
- <input type = "submit" name = "dodaj" value = "Dodaj korisnika">
- <input type = "submit" name = "upit" value = "Prosledi upit"><br>
- ID: <input type = "text" name = "brisi"><input type = "submit" name = "ukloni" value = "Ukloni korisnika"><br>
- <input type = "submit" name = "tabela" value = "Prikazi tabelu">
- </form>
- </body>
- <?php
- $localhost = "localhost";
- $username = "root";
- $password = "";
- $konekcija = new mysqli($localhost,$username,$password);
- $baza = "CREATE DATABASE PraviKorisnici";
- //$konekcija->query($baza) or die($konekcija->error);
- mysqli_select_db($konekcija, "PraviKorisnici");
- $tabela = "CREATE TABLE Unos (
- ID INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
- Ime VARCHAR(15),
- Prezime VARCHAR(15),
- Tip VARCHAR(15)
- )";
- //$konekcija->query($tabela) or die($konekcija->error);
- if(isset($_POST["dodaj"])){
- $ime = $_POST["ime"];
- $prezime = $_POST["prezime"];
- $tip = $_POST["tip"];
- $unos = "INSERT INTO Unos (Ime,Prezime,Tip) VALUES ('$ime','$prezime','$tip')";
- $konekcija->query($unos) or die($konekcija->error);
- }
- if(isset($_POST["upit"])){
- //$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' ";
- $upit = "SELECT * FROM PraviKorisnici.Unos,DrugiKorisnici.DrugiUnos WHERE Unos.ID = '2' AND DrugiUnos.ID = '2' ";
- $rezultat = $konekcija->query($upit) or die($konekcija->error);
- $niz = $rezultat->fetch_all();
- echo "<table align = 'center' border = 1>";
- echo"<tr>";
- echo"<td class = 'class'>ID</td>";
- echo"<td class = 'class'>Ime</td>";
- echo"<td class = 'class'>Prezime</td>";
- echo"<td class = 'class'>Tip</td>";
- echo"<td class = 'class'>Plata</td>";
- echo"<td class = 'class'>Adresa</td>";
- echo"<td class = 'class'>Broj_telefona</td>";
- echo"</tr>";
- foreach($niz as $row){
- //echo "ID: " . $row[0]. " Ime: " . $row[1]. " Prezime: " . $row[2]. " Tip: " . $row[3] . "<br>";
- echo"<tr>";
- echo"<td>".$row[0]."</td>";
- echo"<td>".$row[1]."</td>";
- echo"<td>".$row[2]."</td>";
- echo"<td>".$row[3]."</td>";
- echo"<td>".$row[5]."</td>";
- echo"<td>".$row[6]."</td>";
- echo"<td>".$row[7]."</td>";
- echo"</tr>";
- }
- echo "</table>";
- }
- if(isset($_POST["ukloni"])){
- $brisi = $_POST["brisi"];
- $uklon = "DELETE FROM Unos WHERE Unos.ID = '$brisi'";
- $konekcija->query($uklon) or die($konekcija->error);
- }
- if(isset($_POST["tabela"])){
- echo "<table align = 'center' border = 1>";
- echo"<tr>";
- echo"<td class = 'class'>ID</td>";
- echo"<td class = 'class'>Ime</td>";
- echo"<td class = 'class'>Prezime</td>";
- echo"<td class = 'class'>Tip</td>";
- echo"</tr>";
- $upit1 = "SELECT * FROM Unos";
- $rez = $konekcija->query($upit1);
- $niz1 = $rez->fetch_all();
- foreach($niz1 as $row1){
- echo "<tr>";
- echo "<td>".$row1[0]."</td>";
- echo "<td>".$row1[1]."</td>";
- echo "<td>".$row1[2]."</td>";
- echo "<td>".$row1[3]."</td>";
- echo "</tr>";
- }
- echo "</table>";
- }
- ?>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement