public function registracija($ime, $prezime, $mesto, $drzava, $email, $lozinka) {
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) {
echo die("<script>alert('E-mail adresa nije validna');</script>");
}
$sthandler = $this->connection->prepare('SELECT email FROM korisnik WHERE email=:email');
$sthandler->bindParam(":email", $email, PDO::PARAM_STR);
$sthandler->execute();
if ($sthandler->rowCount() > 0) {
echo die("<script>alert('E-mail adresa je vec u upotrebi');</script><META HTTP-EQUIV='refresh' CONTENT='2'>");
} else {
$sql = "INSERT INTO korisnik VALUES(:ime,:prezime,:mesto,:drzava,:email,:lozinka)";
$stmt = $this->connection->prepare($sql);
$stmt->bindParam(":ime", $ime, PDO::PARAM_STR);
$stmt->bindParam(":prezime", $prezime, PDO::PARAM_STR);
$stmt->bindParam(":mesto", $mesto, PDO::PARAM_STR);
$stmt->bindParam(":drzava", $drzava, PDO::PARAM_STR);
$stmt->bindParam(":email", $email, PDO::PARAM_STR);
$stmt->bindParam(":lozinka", $lozinka, PDO::PARAM_STR);
if (strlen($lozinka) < 4) {
echo die("<script>alert('Lozinka je kraca od 4 karaktera, pokusajte ponovo');</script><META HTTP-EQUIV='refresh' CONTENT='2'>");
} else {
$stmt->execute();
echo "<script>alert('Uspesno izvršena registracija');</script>";
}
}
}