Commit 5c410b7a authored by Nikolaj Klep's avatar Nikolaj Klep
Browse files

prvi

parents
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
\ No newline at end of file
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "firefox",
"request": "launch",
"name": "Firefox",
"url": "http://www2.scptuj.si/~klep.nikolaj/sptrg3a1-24/view",
}
]
}
\ No newline at end of file
{
"sqltools.connections": [
{
"previewLimit": 50,
"server": "www2.scptuj.si",
"port": 9999,
"askForPassword": true,
"driver": "PostgreSQL",
"database": "klep.nikolaj23",
"username": "klep.nikolaj23",
"name": "scptuj"
}
]
}
<?php
include_once "../model/model.php";
include_once "../model/dbconf.php";
class Artikel extends Model
{
private $pdoconn;
public function __construct($pdoconn)
{
$this->pdoconn = $pdoconn;
}
public function getArtikli()
{
$query = "SELECT * FROM artikel;";
$stmt = $this->pdoconn->prepare($query);
$stmt->execute();
return $stmt->fetchAll();
}
public function getArtikelById($id)
{
$query = "SELECT * FROM artikel WHERE id_artikel = ?";
$stmt = $this->pdoconn->prepare($query);
$stmt->execute([$id]);
return $stmt->fetch();
}
public function addArtikel($naziv, $cena, $opis, $zaloga, $id_proiz, $image_file)
{
$sql = "INSERT INTO artikel (naziv, cena, opis, zaloga, proizvajalec_id_proizvajalec, slike) VALUES (?, ?, ?, ?, ?, ?);";
try {
$stmt = $this->pdoconn->prepare($sql);
$stmt->execute([$naziv, $cena, $opis, $zaloga, $id_proiz, $image_file]);
return true;
} catch (PDOException $e) {
echo "Insert artikel failed: " . $e->getMessage();
return false;
}
}
public function kupiArtikel($artikel_id)
{
$sql = "INSERT INTO kosarica (artikel_id_artikel) VALUES (?)";
try {
$stmt = $this->pdoconn->prepare($sql);
$stmt->execute([$artikel_id]);
return true;
} catch (PDOException $e) {
echo "Insert into kosarica failed: " . $e->getMessage();
return false;
}
}
public function deleteArtikel($id)
{
$sql = "DELETE FROM artikel WHERE id_artikel = ?";
$stmt = $this->pdoconn->prepare($sql);
$stmt->execute([$id]);
}
}
?>
\ No newline at end of file
<?php
include_once "../model/model.php";
class Proizvajalec extends Model {
public function getAllProizvajalec(){
$sql = "SELECT * FROM proizvajalec;";
$stmt = $this->dbconn->prepare($sql);
$stmt->execute();
return $stmt->fetchAll();
}
public function getProizvajalecNameById($id)
{
$sql = "SELECT naziv FROM proizvajalec WHERE id_proizvajalec = ?;";
$stmt = $this->dbconn->prepare($sql);
$stmt->execute([$id]);
$result = $stmt->fetch();
$naziv = $result['naziv'];
return $naziv;
}
}
?>
\ No newline at end of file
<?php
include_once "../model/model.php";
include_once "../model/dbconf.php";
class Kosarica extends Model
{
private $pdoconn;
public function __construct($pdoconn)
{
$this->pdoconn = $pdoconn;
}
public function getKosaricaItems()
{
$query = "SELECT * FROM kosarica;";
$stmt = $this->pdoconn->prepare($query);
$stmt->execute();
return $stmt->fetchAll();
}
public function removeItemFromKosarica($id)
{
$sql = "DELETE FROM kosarica WHERE id_kosarice = ?";
$stmt = $this->pdoconn->prepare($sql);
$stmt->execute([$id]);
}
}
?>
\ No newline at end of file
<?php
include_once "../model/model.php";
class narocilo extends Model
{
private $m_datum;
private $m_kolicina;
private $m_id_uporabnik;
private $m_id_artikel;
function add_narocilo()
{
if (!$this->db_conn)
return;
return $this->execute_sql_query("INSERT INTO sptrg_narocilo (datum, kolicina, id_uporabnik, id_artikel) VALUES (:v1, :v2, :v3, :v4)",
$this->m_datum, $this->m_kolicina, $this->m_id_uporabnik, $this->m_id_artikel);
}
}
<?php
include_once "../model/model.php";
class profil extends Model
{
private $m_id_profil;
private $m_tip_profila;
private $m_opis;
function add_profil()
{
if (!$this->db_conn)
return;
return $this->execute_sql_query("INSERT INTO sptrg_profil (id_profil, tip_profila, opis) VALUES (:v1, :v2, :v3)",
$this->m_id_profil, $this->m_tip_profila, $this->m_opis);
}
}
<?php
include_once "../model/model.php";
class Uporabnik extends Model
{
private $id;
private $ime;
private $priimek;
private $username;
private $password;
public function getDataUporabnik()
{
$sql = "select * from uporabnik;";
$stmt = $this->dbconn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll();
//return $stmt->fetxhAll();
return $result;
}
public function loginUser($user,$geslo){
$sql = "select count(*) from uporabnik where username=? and password = ?";
$stmt = $this->dbconn->prepare($sql);
$stmt->execute([$user, $geslo]);
$count = $stmt->fetchColumn();
if($count == 1){
return true;
}else{
return false;
}
}
}
<?php
$host = 'www2.scptuj.si';
$dbname = 'klep.nikolaj23';
$user = 'klep.nikolaj23';
$pass = 'muca0000';
try {
$pdo = new PDO("pgsql:host=$host;dbname=$dbname", $user, $pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo "Connection failed: " . $e->getMessage();
} //Error Handling
\ No newline at end of file
<?php
include_once "../model/dbconf.php";
class Model{
protected $dbconn;
function __construct($pdo){
$this->dbconn = $pdo;
}
}
?>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>O NAS</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
nav {
background-color: #333;
color: #fff;
padding: 10px 20px;
}
ul {
list-style-type: none;
padding: 0;
margin: 0;
}
li {
display: inline;
margin-right: 20px;
}
a {
color: #fff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.container {
max-width: 800px;
margin: 50px auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
h1 {
color: #333;
text-align: center;
}
p {
color: #666;
text-align: center;
}
</style>
</head>
<body>
<nav>
<ul>
<li><a href="homepage.php">Nazaj</a></li>
</ul>
</nav>
<div class="container">
<h1>Kdo sem?</h1>
<p>SEM JUNAK</p>
<p</p>
</div>
</body>
</html>
<?php
$host = "www2.scptuj.si";
$dbname = "klep.nikolaj23";
$user = "mklep.nikolaj23";
$pass = "muca0000";
?>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #000 !important; /* Set background color to black */
color: #fff !important; /* Set text color to white */
}
nav {
background-color: #333;
color: #333;
padding: 10px 20px;
}
ul {
list-style-type: none;
padding: 0;
margin: 0;
}
li {
display: inline;
margin-right: 20px;
}
a {
color: #fff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Spletna Trgovina</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<!DOCTYPE html>
<html lang="en">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
nav {
background-color: #333;
color: #fff;
padding: 10px 20px;
}
ul {
list-style-type: none;
padding: 0;
margin: 0;
}
li {
display: inline;
margin-right: 20px;
}
a {
color: #fff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.container {
max-width: 800px;
margin: 50px auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
h1 {
color: #333;
text-align: center;
}
p {
color: #666;
text-align: center;
}
/* Additional CSS for the image */
.image-container {
text-align: center;
margin-top: 20px;
}
img {
max-width: 100%;
height: auto;
}
</style>
</head>
<body>
<nav>
<ul>
<!-- Updated link to redirect to 'izpis_artikla.php' -->
<li><a href="vnos_artikla.php">Nazaj</a></li>
<li><a href="about.php">O nas</a></li>
</ul>
</nav>
<div class="container">
<h1>Dobrodosli na Klepovo spletno stran</h1>
<p>Mogoce dobis virus</p>
</div>
<div class="image-container">
<img src="hej.jpg" alt="slike ni :(">
</div>
</body>
</html>
<?php
include_once "header.php";
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ini_set('display_errors', 1);
include_once "../controller/Artikel.php";
include_once "../controller/Proizvajalec.php";
include_once "../view/layouts/meni.php";
$art = new Artikel($pdo);
$proizvajalec = new Proizvajalec($pdo);
if (isset($_GET['bid'])) {
$art->deleteArtikel($_GET['bid']);
header("Location: izpis_artikla.php");
exit();
}
if (isset($_GET['kid'])) {
if ($art->kupiArtikel($_GET['kid'])) {
echo "<script>alert('Artikel uspešno dodan v košarico!');</script>";
} else {
echo "<script>alert('Napaka pri dodajanju artikla v košarico!');</script>";
}
}
$result = $art->getArtikli();
if ($result) {
include_once "header.php";
?>
<body>
<div class="container">
<h3 style="margin-top: 15px; font-weight: bold;">Artikli:</h3>
<div class="table-responsive">
<table class="table table-dark table-striped">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Naziv</th>
<th scope="col">Cena</th>
<th scope="col">Opis</th>
<th scope="col">Zaloga</th>
<th scope="col">Proizvajalec</th>
<th scope="col">Slika</th>
<th scope="col">Kupi</th>
<th scope="col">Izbriši</th>
</tr>
</thead>
<tbody>
<?php foreach ($result as $row) { ?>
<tr>
<td><?php echo $row['id_artikel']; ?></td>
<td><?php echo $row['naziv']; ?></td>
<td><?php echo $row['cena']; ?></td>
<td><?php echo $row['opis']; ?></td>
<td><?php echo $row['zaloga']; ?></td>
<td><?php echo $proizvajalec->getProizvajalecNameById($row['proizvajalec_id_proizvajalec']); ?></td>
<td>
<?php $slika_pot = 'https://www2.scptuj.si/~klep.nikolaj/sptrg3a1-24/' . $row['slike']; ?>
<img src="<?php echo $slika_pot; ?>" alt="" height="100px">
</td>
<td>
<a href="izpis_artikla.php?kid=<?php echo $row['id_artikel']; ?>" class="btn btn-success">Kupi</a>
</td>
<td>
<a href="izpis_artikla.php?bid=<?php echo $row['id_artikel']; ?>" class="btn btn-danger">Izbriši</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</body>
<?php
}
?>
<?php
include_once "head.php";
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ini_set('display_errors', 1);
include_once "../controller/kosarica.php";
include_once "../controller/Artikel.php";
include_once "../controller/Proizvajalec.php";
include_once "../view/layouts/meni.php";
$kosarica = new Kosarica($pdo);
$art = new Artikel($pdo);
$proizvajalec = new Proizvajalec($pdo);
if (isset($_GET['rid'])) {
$kosarica->removeItemFromKosarica($_GET['rid']);
header("Location: izpis_kosarice.php");
exit();
}
$result = $kosarica->getKosaricaItems();
if ($result) {
include_once "header.php";
?>
<body style="background-color: black; color: white;">
<div class="container">
<h3 style="margin-top: 15px; font-weight: bold;">Vaša košarica:</h3>
<div class="table-responsive">
<table class="table table-dark table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Naziv</th>
<th scope="col">Cena</th>
<th scope="col">Proizvajalec</th>
<th scope="col">Slika</th>
<th scope="col">Odstrani</th>
</tr>
</thead>
<tbody>
<?php foreach ($result as $row) {
$artikel = $art->getArtikelById($row['artikel_id_artikel']);
if ($artikel) { ?>
<tr>
<td><?php echo $row['id_kosarice']; ?></td>
<td><?php echo $artikel['naziv']; ?></td>
<td><?php echo $artikel['cena']; ?></td>
<td><?php echo $proizvajalec->getProizvajalecNameById($artikel['proizvajalec_id_proizvajalec']); ?></td>
<td>
<?php $slika_pot = 'https://www2.scptuj.si/~klep.nikolaj/sptrg3a1-24/view/' . $artikel['slike']; ?>
<img src="<?php echo $slika_pot; ?>" alt="" height="100px">
</td>
<td><a href='izpis_kosarice.php?rid=<?php echo $row['id_kosarice']; ?>' class="btn btn-danger">Odstrani</a></td>
</tr>
<?php } else { ?>
<tr>
<td colspan="6">Izdelek ni bil najden.</td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>
</div>
</body>
<?php } ?>
<?php
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ini_set('display_errors', 1);
include_once "../controller/uporabnik.php";
include_once "../view/layouts/meni.php";
$upor = new Uporabnik($pdo);
$result = $upor->getDataUporabnik();
if ($result) {
include_once "header.php";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Uporabniki</title>
<style>
body {
background-color: black;
color: white;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
</style>
</head>
<body>
<h3 style="color: black; margin-left: 440px; margin-top: 15px; font-weight: bold;">Uporabniki</h3>
<div class="container">
<table class="table table-active table-sm" style="margin-top: 20px; margin-left: 35px;">
<thead>
<tr>
<th>ID</th>
<th>Ime</th>
<th>Priimek</th>
<th>Naslov</th>
<th>Poštna številka</th>
<th>Kraj</th>
<th>Datum rojstva</th>
<th>Telefonska številka</th>
<th>Email</th>
<th>Uporabniško ime</th>
<th>Geslo</th>
</tr>
</thead>
<tbody>
<?php foreach ($result as $row) : ?>
<tr>
<td><?= $row['id_uporabnika']; ?></td>
<td><?= $row['ime']; ?></td>
<td><?= $row['priimek']; ?></td>
<td><?= $row['naslov']; ?></td>
<td><?= $row['postna_st']; ?></td>
<td><?= $row['kraj']; ?></td>
<td><?= $row['datum_rojstva']; ?></td>
<td><?= $row['telefonska_st']; ?></td>
<td><?= $row['email']; ?></td>
<td><?= $row['uporabnisko_jme']; ?></td>
<td><?= $row['geslo']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment