Index: src/main/java/com/example/cookbook/controller/HomeController.java
===================================================================
--- src/main/java/com/example/cookbook/controller/HomeController.java	(revision aea04dd11bd317791370e0f33f770b3a4f0abed3)
+++ src/main/java/com/example/cookbook/controller/HomeController.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
@@ -2,19 +2,16 @@
 
 
-import com.example.cookbook.model.Komentar;
-import com.example.cookbook.model.Recept;
-import com.example.cookbook.model.Slika;
-import com.example.cookbook.model.Sostojka;
+import com.example.cookbook.model.*;
 import com.example.cookbook.model.exception.ReceptNeEPronajdenException;
-import com.example.cookbook.service.KomentariService;
-import com.example.cookbook.service.ReceptService;
-import com.example.cookbook.service.SlikiService;
-import com.example.cookbook.service.SostojkiService;
+import com.example.cookbook.service.*;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 
 import java.sql.SQLException;
+import java.time.LocalDateTime;
 import java.util.List;
 
@@ -29,7 +26,9 @@
     private final KomentariService komentariService;
 
+    private final KorisniciService korisniciService;
+
     public HomeController(ReceptService receptService,
                           SlikiService slikiService,
-                          SostojkiService sostojkiService, KomentariService komentariService) {
+                          SostojkiService sostojkiService, KomentariService komentariService, KorisniciService korisniciService) {
 
         this.receptService = receptService;
@@ -37,4 +36,5 @@
         this.sostojkiService = sostojkiService;
         this.komentariService = komentariService;
+        this.korisniciService = korisniciService;
     }
 
@@ -59,4 +59,5 @@
         List<Sostojka> sostojki;
         List<Komentar> komentari;
+        List<Korisnik> posetiteli;
         try {
             recept = receptService.findById(id);
@@ -64,4 +65,5 @@
             sostojki = sostojkiService.findAllById(id);
             komentari = komentariService.findAllById(id);
+            posetiteli = korisniciService.findAllByRole(TipKorisnik.Posetitel);
         } catch (SQLException e) {
             return "redirect:/error-page/SQL%20Exception";
@@ -73,5 +75,24 @@
         model.addAttribute("sostojki", sostojki);
         model.addAttribute("komentari", komentari);
+        model.addAttribute("posetiteli", posetiteli);
         return "recept";
+    }
+
+    @PostMapping("/komentar/{id}")
+    public String processKomentar(@PathVariable Long id,
+                                  @RequestParam Integer ocena,
+                                  @RequestParam String komentar,
+                                  @RequestParam String telefon){
+        if (id == null){
+            return "redirect:/error-page/Ne%20dodavanje%20komentar(Identifikatorot%20na%20receptot%20ne%20postoi)";
+        }
+        try {
+            komentariService.add(telefon, id, ocena, komentar);
+        } catch (SQLException e) {
+            return "redirect:/error-page/SQL%20Exception";
+        }catch (IllegalArgumentException e){
+            return "redirect:/error-page/Illegal%20Arguments";
+        }
+        return "redirect:/recept/" + id;
     }
 
Index: src/main/java/com/example/cookbook/model/Komentar.java
===================================================================
--- src/main/java/com/example/cookbook/model/Komentar.java	(revision aea04dd11bd317791370e0f33f770b3a4f0abed3)
+++ src/main/java/com/example/cookbook/model/Komentar.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
@@ -24,4 +24,12 @@
     public void setImePrezime(String imePrezime) {
         this.imePrezime = imePrezime;
+    }
+
+    public Komentar(LocalDateTime komData, String telefon, Long recId, Integer ocena, String text) {
+        this.komData = komData;
+        this.telefon = telefon;
+        this.recId = recId;
+        this.ocena = ocena;
+        this.text = text;
     }
 
Index: src/main/java/com/example/cookbook/model/Korisnik.java
===================================================================
--- src/main/java/com/example/cookbook/model/Korisnik.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
+++ src/main/java/com/example/cookbook/model/Korisnik.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
@@ -0,0 +1,54 @@
+package com.example.cookbook.model;
+
+public class Korisnik {
+
+    private String telefon;
+
+    private String ime;
+
+    private String prezime;
+
+    private TipKorisnik tipKorisnik;
+
+    public Korisnik(String telefon, String ime, String prezime, TipKorisnik tipKorisnik) {
+        this.telefon = telefon;
+        this.ime = ime;
+        this.prezime = prezime;
+        this.tipKorisnik = tipKorisnik;
+    }
+
+    public Korisnik() {
+    }
+
+    public String getTelefon() {
+        return telefon;
+    }
+
+    public void setTelefon(String telefon) {
+        this.telefon = telefon;
+    }
+
+    public String getIme() {
+        return ime;
+    }
+
+    public void setIme(String ime) {
+        this.ime = ime;
+    }
+
+    public String getPrezime() {
+        return prezime;
+    }
+
+    public void setPrezime(String prezime) {
+        this.prezime = prezime;
+    }
+
+    public TipKorisnik getTipKorisnik() {
+        return tipKorisnik;
+    }
+
+    public void setTipKorisnik(TipKorisnik tipKorisnik) {
+        this.tipKorisnik = tipKorisnik;
+    }
+}
Index: src/main/java/com/example/cookbook/model/TipKorisnik.java
===================================================================
--- src/main/java/com/example/cookbook/model/TipKorisnik.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
+++ src/main/java/com/example/cookbook/model/TipKorisnik.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
@@ -0,0 +1,5 @@
+package com.example.cookbook.model;
+
+public enum TipKorisnik {
+    Vraboten, Posetitel
+}
Index: src/main/java/com/example/cookbook/repository/KomentariRepository.java
===================================================================
--- src/main/java/com/example/cookbook/repository/KomentariRepository.java	(revision aea04dd11bd317791370e0f33f770b3a4f0abed3)
+++ src/main/java/com/example/cookbook/repository/KomentariRepository.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
@@ -6,8 +6,5 @@
 import org.springframework.stereotype.Repository;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import java.sql.*;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
@@ -48,3 +45,22 @@
         return komentari;
     }
+
+    public void save(Komentar komentar) throws SQLException {
+        Connection connection = DB.getConnection();
+
+        String query = "insert into komentari (kom_data, telefon, rec_id, ocena, text) values \n" +
+                "        (?, ?, ?, ?, ?);";
+
+        PreparedStatement prepStm = connection.prepareStatement(query);
+        prepStm.setObject(1, komentar.getKomData());
+        prepStm.setString(2, komentar.getTelefon());
+        prepStm.setLong(3, komentar.getRecId());
+        prepStm.setInt(4, komentar.getOcena());
+        prepStm.setString(5, komentar.getText());
+
+        prepStm.executeUpdate();
+
+        prepStm.close();
+        DB.closeConnection();
+    }
 }
Index: src/main/java/com/example/cookbook/repository/KorisniciRepository.java
===================================================================
--- src/main/java/com/example/cookbook/repository/KorisniciRepository.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
+++ src/main/java/com/example/cookbook/repository/KorisniciRepository.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
@@ -0,0 +1,55 @@
+package com.example.cookbook.repository;
+
+
+import com.example.cookbook.dbConfig.DB;
+import com.example.cookbook.model.Komentar;
+import com.example.cookbook.model.Korisnik;
+import com.example.cookbook.model.TipKorisnik;
+import org.springframework.stereotype.Repository;
+
+import java.sql.*;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+
+@Repository
+public class KorisniciRepository {
+    public List<Korisnik> findAllByRole(TipKorisnik tipKorisnik) throws SQLException {
+        Connection connection = DB.getConnection();
+
+        String query;
+
+        if (tipKorisnik == TipKorisnik.Posetitel){
+            query = "select p.telefon, k.kor_ime, k.prezime\n" +
+                    "from posetiteli p\n" +
+                    "    left join korisnici k on p.telefon = k.telefon";
+        } else {
+            query = "select v.telefon, k.kor_ime, k.prezime\n" +
+                    "from vraboteni v\n" +
+                    "    left join korisnici k on v.telefon = k.telefon";
+        }
+
+        Statement stm = connection.createStatement();
+
+
+        ResultSet result = stm.executeQuery(query);
+        List<Korisnik> korisnici = new ArrayList<>();
+
+        while (result.next()){
+            Korisnik korisnik = new Korisnik();
+            korisnik.setTelefon(result.getString("telefon"));
+            korisnik.setIme(result.getString("kor_ime"));
+            korisnik.setPrezime(result.getString("prezime"));
+            korisnik.setTipKorisnik(tipKorisnik);
+            korisnici.add(korisnik);
+        }
+
+        result.close();
+        stm.close();
+        DB.closeConnection();
+
+        return korisnici;
+    }
+
+
+}
Index: src/main/java/com/example/cookbook/service/KomentariService.java
===================================================================
--- src/main/java/com/example/cookbook/service/KomentariService.java	(revision aea04dd11bd317791370e0f33f770b3a4f0abed3)
+++ src/main/java/com/example/cookbook/service/KomentariService.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
@@ -9,3 +9,5 @@
 
     List<Komentar> findAllById(Long recId) throws SQLException;
+
+    void add(String telefon, Long id, Integer ocena, String komentar) throws SQLException;
 }
Index: src/main/java/com/example/cookbook/service/KorisniciService.java
===================================================================
--- src/main/java/com/example/cookbook/service/KorisniciService.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
+++ src/main/java/com/example/cookbook/service/KorisniciService.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
@@ -0,0 +1,18 @@
+package com.example.cookbook.service;
+
+import com.example.cookbook.model.Komentar;
+import com.example.cookbook.model.Korisnik;
+import com.example.cookbook.model.TipKorisnik;
+
+import java.sql.SQLException;
+import java.time.LocalDateTime;
+import java.util.List;
+
+public interface KorisniciService {
+
+
+    List<Korisnik> findAllByRole(TipKorisnik posetitel) throws SQLException;
+
+
+
+}
Index: src/main/java/com/example/cookbook/service/impl/KomentariServiceImpl.java
===================================================================
--- src/main/java/com/example/cookbook/service/impl/KomentariServiceImpl.java	(revision aea04dd11bd317791370e0f33f770b3a4f0abed3)
+++ src/main/java/com/example/cookbook/service/impl/KomentariServiceImpl.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
@@ -8,4 +8,5 @@
 
 import java.sql.SQLException;
+import java.time.LocalDateTime;
 import java.util.List;
 
@@ -23,3 +24,11 @@
         return komentariRepository.findAllByRecId(recId);
     }
+
+    @Override
+    public void add(String telefon, Long id, Integer ocena, String komentar) throws SQLException {
+        if (telefon.isBlank() || ocena == null){
+            throw new IllegalArgumentException();
+        }
+        komentariRepository.save(new Komentar(LocalDateTime.now(), telefon, id, ocena, komentar));
+    }
 }
Index: src/main/java/com/example/cookbook/service/impl/KorisniciServiceImpl.java
===================================================================
--- src/main/java/com/example/cookbook/service/impl/KorisniciServiceImpl.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
+++ src/main/java/com/example/cookbook/service/impl/KorisniciServiceImpl.java	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
@@ -0,0 +1,32 @@
+package com.example.cookbook.service.impl;
+
+
+import com.example.cookbook.model.Komentar;
+import com.example.cookbook.model.Korisnik;
+import com.example.cookbook.model.TipKorisnik;
+import com.example.cookbook.repository.KorisniciRepository;
+import com.example.cookbook.service.KorisniciService;
+import org.springframework.stereotype.Service;
+
+import java.sql.SQLException;
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Service
+public class KorisniciServiceImpl implements KorisniciService {
+
+
+    private final KorisniciRepository korisniciRepository;
+
+    public KorisniciServiceImpl(KorisniciRepository korisniciRepository) {
+        this.korisniciRepository = korisniciRepository;
+    }
+
+    @Override
+    public List<Korisnik> findAllByRole(TipKorisnik tipKorisnik) throws SQLException {
+        return korisniciRepository.findAllByRole(tipKorisnik);
+    }
+
+
+
+}
Index: src/main/resources/templates/recept.html
===================================================================
--- src/main/resources/templates/recept.html	(revision aea04dd11bd317791370e0f33f770b3a4f0abed3)
+++ src/main/resources/templates/recept.html	(revision d4d8fb910efb9952fb7c668392de16325221a0e1)
@@ -83,5 +83,7 @@
                 <select id="telefon" name="telefon" required>
                     <option selected></option>
-                    <option th:each="tel : ${telefoni}" th:text="tel" th:value="tel"></option>
+                    <option th:each="posetitel : ${posetiteli}"
+                            th:text="${posetitel.telefon}"
+                            th:value="${posetitel.telefon}"></option>
                 </select>
             </div>
