verifica
This commit is contained in:
parent
2c82d90dd4
commit
5f80048cec
20 changed files with 999 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
.idea
|
.idea
|
||||||
docs
|
docs
|
||||||
|
W3Schools-2022-09-06
|
||||||
|
|
1
db/.gitignore
vendored
Normal file
1
db/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
mysql
|
20
db/compose.yml
Normal file
20
db/compose.yml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
version: '3.1'
|
||||||
|
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: mariadb:10.11
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: WhiXard420.
|
||||||
|
volumes:
|
||||||
|
- ./mysql:/var/lib/mysql:Z
|
||||||
|
|
||||||
|
phpmyadmin:
|
||||||
|
image: phpmyadmin
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 8080:80
|
||||||
|
environment:
|
||||||
|
- PMA_ARBITRARY=1
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
require_once('../../includes/functions.php');
|
||||||
|
checkSession();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$connection = getDbConnection();
|
||||||
|
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
$prepare = $connection->prepare("INSERT INTO `modello` (`codice`, `descrizione`, `quantita`, `tipologia`) VALUES (NULL, ?, ?, ?);");
|
||||||
|
$prepare->bindParam(1, $_POST['descrizione']);
|
||||||
|
$prepare->bindParam(2, $_POST['quantita']);
|
||||||
|
$prepare->bindParam(3, $_POST['tipologia']);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$prepare->execute();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo "Impossibile inserire il modello, controllare i dati";
|
||||||
|
die($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Login</title>
|
||||||
|
<link rel="stylesheet" href="../../includes/css/pico.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="container">
|
||||||
|
<a href="../dashboard.php" class="button">Torna alla dashboard</a>
|
||||||
|
<h2>Operazione eseguita con successo</h2>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
require_once('../../includes/functions.php');
|
||||||
|
checkSession();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$connection = getDbConnection();
|
||||||
|
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
$prepare = $connection->prepare("DELETE FROM modello WHERE codice = ?;");
|
||||||
|
$prepare->bindParam(1, $_POST['codice']);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$prepare->execute();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo "Impossibile inserire il modello, controllare i dati";
|
||||||
|
die($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Login</title>
|
||||||
|
<link rel="stylesheet" href="../../includes/css/pico.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="container">
|
||||||
|
<a href="../dashboard.php" class="button">Torna alla dashboard</a>
|
||||||
|
<h2>Operazione eseguita con successo</h2>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
require_once('../../includes/functions.php');
|
||||||
|
checkSession();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$connection = getDbConnection();
|
||||||
|
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
$tipologia = $_GET["tipologia"];
|
||||||
|
$prepare = $connection->prepare("SELECT t.nome
|
||||||
|
FROM modello AS m
|
||||||
|
INNER JOIN biciclette.tipologia t on m.tipologia = t.codice
|
||||||
|
WHERE m.tipologia = ?
|
||||||
|
ORDER BY t.codice");
|
||||||
|
|
||||||
|
$prepare->bindParam(1, $tipologia);
|
||||||
|
$prepare->execute();
|
||||||
|
|
||||||
|
if ($prepare->rowCount() >= 1) {
|
||||||
|
$bici = $prepare->fetchAll();
|
||||||
|
$quantita = $prepare->rowCount();
|
||||||
|
$tipologia = $bici[0]['nome'];
|
||||||
|
} else {
|
||||||
|
echo "nessuna quantita";
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Login</title>
|
||||||
|
<link rel="stylesheet" href="../../includes/css/pico.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="container">
|
||||||
|
<a href="../dashboard.php" class="button">Torna alla dashboard</a>
|
||||||
|
|
||||||
|
<h1>Quantita per tipologia: <?php echo $tipologia ?></h1>
|
||||||
|
<h1><?= $quantita ?></h1>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
82
moro_detto_rocco_andrea_biciclette/admin/dashboard.php
Normal file
82
moro_detto_rocco_andrea_biciclette/admin/dashboard.php
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
require_once('../includes/functions.php');
|
||||||
|
|
||||||
|
checkSession();
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$connection = getDbConnection();
|
||||||
|
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
$marche = $connection->query("SELECT * FROM tipologia")->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$biciclette = $connection->query("SELECT * FROM modello")->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Admin Dashboard</title>
|
||||||
|
<link rel="stylesheet" href="../includes/css/pico.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="container">
|
||||||
|
<h1>Admin Dashboard</h1>
|
||||||
|
<a href="logout.php" class="button">Logout</a>
|
||||||
|
|
||||||
|
<!-- Tipologia Section -->
|
||||||
|
<h2>Tipologia</h2>
|
||||||
|
<form method="get" action="actions/getQuantityTipologia.php">
|
||||||
|
<label for="tipologia">Tipologia:</label>
|
||||||
|
<select name="tipologia" aria-label="Cerca per tipologia" required>
|
||||||
|
<option selected disabled value="">
|
||||||
|
Cerca per Tipologia
|
||||||
|
</option>
|
||||||
|
<?php foreach ($marche as $rw) : ?>
|
||||||
|
<option value=<?= $rw["codice"] ?>><?= $rw["nome"] ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
<button type="submit">Cerca</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- Add bici Section -->
|
||||||
|
<h2>Aggiungi Bicicletta</h2>
|
||||||
|
<form method="post" action="actions/addNewBike.php">
|
||||||
|
<label for="descrizione">Descrizione</label>
|
||||||
|
<input type="text" name="descrizione" id="descrizione" required>
|
||||||
|
<label for="quantita">Quantità</label>
|
||||||
|
<input type="text" name="quantita" id="quantita" required>
|
||||||
|
<label for="tipologia">Tipologia:</label>
|
||||||
|
<select name="tipologia" aria-label="Cerca per tipologia" required>
|
||||||
|
<option selected disabled value="">
|
||||||
|
Cerca per Tipologia
|
||||||
|
</option>
|
||||||
|
<?php foreach ($marche as $rw) : ?>
|
||||||
|
<option value=<?= $rw["codice"] ?>><?= $rw["nome"] ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
<button type="submit">Aggiungi</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!--Delete biciclette-->
|
||||||
|
<h2>Cancella biciclette</h2>
|
||||||
|
<form method="post" action="actions/deleteBike.php">
|
||||||
|
<label for="codice">Bici:</label>
|
||||||
|
<select name="codice" aria-label="Seleziona bici" required>
|
||||||
|
<option selected disabled value="">
|
||||||
|
Seleziona Bicicletta
|
||||||
|
</option>
|
||||||
|
<?php foreach ($biciclette as $rw) : ?>
|
||||||
|
<option value=<?= $rw["codice"] ?>><?= $rw["descrizione"] ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
<button type="submit">Cancella</button>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
66
moro_detto_rocco_andrea_biciclette/admin/login.php
Normal file
66
moro_detto_rocco_andrea_biciclette/admin/login.php
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
require_once '../includes/functions.php';
|
||||||
|
$error = $_SESSION["error"];
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
try {
|
||||||
|
$connection = getDbConnection();
|
||||||
|
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
|
||||||
|
$username = $_POST['username'];
|
||||||
|
$password = $_POST['password'];
|
||||||
|
|
||||||
|
$stmt = $connection->prepare("SELECT * FROM utenti WHERE user = :username AND password = :password");
|
||||||
|
$stmt->bindParam(':username', $username);
|
||||||
|
$stmt->bindParam(':password', $password);
|
||||||
|
$stmt->execute();
|
||||||
|
$user = $stmt->fetch();
|
||||||
|
|
||||||
|
if ($user) {
|
||||||
|
if ($user['llivello'] == 0) {
|
||||||
|
$_SESSION['user_id'] = $user['idut'];
|
||||||
|
$_SESSION['username'] = $user['user'];
|
||||||
|
$_SESSION['livello'] = $user['livello'];
|
||||||
|
$_SESSION["login"] = true;
|
||||||
|
|
||||||
|
header('Location: dashboard.php');
|
||||||
|
} else {
|
||||||
|
$_SESSION["error"] = "Invalid username or password.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$_SESSION["error"] = "Utente non trovato.";
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$error = "Error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Login</title>
|
||||||
|
<link rel="stylesheet" href="../includes/css/pico.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="container">
|
||||||
|
<h1>Login</h1>
|
||||||
|
<?php if (!empty($_SESSION["error"])): ?>
|
||||||
|
<div class="alert alert-danger"><?php echo $_SESSION["error"]; ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<form method="post" action="">
|
||||||
|
<label for="username">Username:</label>
|
||||||
|
<input <?php if (!empty($_SESSION["error"])):
|
||||||
|
echo "aria-invalid=\"true\""; endif; ?> type="text" id="username" name="username" required>
|
||||||
|
|
||||||
|
<label for="password">Password:</label>
|
||||||
|
<input <?php if (!empty($_SESSION["error"])):
|
||||||
|
echo "aria-invalid=\"true\""; endif; ?> type="password" id="password" name="password" required>
|
||||||
|
|
||||||
|
<button type="submit">Login</button>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
5
moro_detto_rocco_andrea_biciclette/admin/logout.php
Normal file
5
moro_detto_rocco_andrea_biciclette/admin/logout.php
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
session_destroy();
|
||||||
|
header("location:login.php");
|
||||||
|
|
4
moro_detto_rocco_andrea_biciclette/includes/css/pico.min.css
vendored
Normal file
4
moro_detto_rocco_andrea_biciclette/includes/css/pico.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
2
moro_detto_rocco_andrea_biciclette/includes/footer.php
Normal file
2
moro_detto_rocco_andrea_biciclette/includes/footer.php
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<script src="/moro_detto_rocco_verifica_php/includes/js/bootstrap.bundle.js"
|
||||||
|
crossorigin="anonymous"></script>
|
24
moro_detto_rocco_andrea_biciclette/includes/functions.php
Normal file
24
moro_detto_rocco_andrea_biciclette/includes/functions.php
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
$host = "127.0.0.1";
|
||||||
|
$database = "biciclette";
|
||||||
|
$user = "pdo";
|
||||||
|
$password = "";
|
||||||
|
|
||||||
|
function getDbConnection()
|
||||||
|
{
|
||||||
|
global $host, $database, $user, $password, $database;
|
||||||
|
return new PDO("mysql:host=$host;dbname=$database", $user, $password);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkSession()
|
||||||
|
{
|
||||||
|
if (empty($_SESSION["llivello"]) || empty($_SESSION["login"])) {
|
||||||
|
if($_SESSION["llivello"] != 0){
|
||||||
|
$_SESSION["error"] = "Errore interno (Sessione non trovata)";
|
||||||
|
header("Location: login.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
moro_detto_rocco_andrea_biciclette/includes/head.php
Normal file
1
moro_detto_rocco_andrea_biciclette/includes/head.php
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<link rel="stylesheet" href="includes/css/pico.min.css" >
|
96
moro_detto_rocco_andrea_biciclette/index.php
Normal file
96
moro_detto_rocco_andrea_biciclette/index.php
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
<?php
|
||||||
|
require "includes/functions.php";
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$connection = getDbConnection();
|
||||||
|
$modello = $connection->prepare("SELECT codice, nome FROM tipologia");
|
||||||
|
$modello->execute();
|
||||||
|
|
||||||
|
if (empty($_GET["cod"])) {
|
||||||
|
$prepare = $connection->prepare("SELECT m.codice, m.descrizione, m.quantita, m.tipologia, t.nome
|
||||||
|
FROM modello AS m
|
||||||
|
INNER JOIN biciclette.tipologia t on m.tipologia = t.codice
|
||||||
|
ORDER BY codice");
|
||||||
|
} else {
|
||||||
|
$codice_modello = $_GET["cod"];
|
||||||
|
$prepare = $connection->prepare("SELECT m.codice, m.descrizione, m.quantita, t.nome
|
||||||
|
FROM modello AS m
|
||||||
|
INNER JOIN biciclette.tipologia t on m.tipologia = t.codice
|
||||||
|
WHERE m.tipologia = ?
|
||||||
|
ORDER BY t.codice");
|
||||||
|
$prepare->bindParam(1, $codice_modello);
|
||||||
|
}
|
||||||
|
|
||||||
|
$prepare->execute();
|
||||||
|
$connection = null;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die ("Error!: " . $e->getMessage() . "<br/>");
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>HTML</title>
|
||||||
|
<?php require "includes/head.php"; ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<main class="container">
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Acme Corp</strong></li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<form>
|
||||||
|
<select name="favorite-cuisine" aria-label="Cerca per Marca" required
|
||||||
|
onchange="redirectToMarca(this)">
|
||||||
|
<option selected disabled value="">
|
||||||
|
Cerca per Marca
|
||||||
|
</option>
|
||||||
|
<option value="">Tutte</option>
|
||||||
|
<?php foreach ($modello->fetchAll() as $rw) : ?>
|
||||||
|
<option value=<?= $rw["codice"] ?>><?= $rw["nome"] ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#">Login</a></li>
|
||||||
|
<li><a href="index.php">Home</a></li>
|
||||||
|
<li><a href="listino.php">Listino</a></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="grid">
|
||||||
|
<?php foreach ($prepare->fetchAll() as $row) : ?>
|
||||||
|
<?= "<div>" ?>
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<a href=<?= "dettagli.php?cod=" . $row["codice"] ?>><b><?= $row["descrizione"] ?></b></a>
|
||||||
|
</header>
|
||||||
|
<?= $row["nome"] ?>
|
||||||
|
<footer>Quantità: <?= $row["quantita"] ?></footer>
|
||||||
|
</article>
|
||||||
|
<?= "</div>" ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function redirectToMarca(selectElement) {
|
||||||
|
const selectedMarca = selectElement.value;
|
||||||
|
if (selectedMarca) {
|
||||||
|
window.location.href = `index.php?cod=${encodeURIComponent(selectedMarca)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
</html>
|
72
moro_detto_rocco_andrea_biciclette/listino.php
Normal file
72
moro_detto_rocco_andrea_biciclette/listino.php
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
require "includes/functions.php";
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$connection = getDbConnection();
|
||||||
|
$prepare = $connection->prepare("SELECT m.codice, m.descrizione, m.quantita, t.nome, t.codice AS codice_modello
|
||||||
|
FROM modello AS m
|
||||||
|
INNER JOIN biciclette.tipologia t on m.tipologia = t.codice
|
||||||
|
ORDER BY m.codice");
|
||||||
|
|
||||||
|
$prepare->execute();
|
||||||
|
$connection = null;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die ("Error!: " . $e->getMessage() . "<br/>");
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>HTML</title>
|
||||||
|
<?php require "includes/head.php"; ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<main class="container">
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Acme Corp</strong></li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#">Login</a></li>
|
||||||
|
<li><a href="index.php">Home</a></li>
|
||||||
|
<li><a href="listino.php">Listino</a></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="grid">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Codice</th>
|
||||||
|
<th>Descrizione</th>
|
||||||
|
<th>Quantità</th>
|
||||||
|
<th>Tipologia</th>
|
||||||
|
</tr>
|
||||||
|
<?php foreach ($prepare->fetchAll() as $model) : ?>
|
||||||
|
<tr>
|
||||||
|
<td><?= $model["codice"] ?></td>
|
||||||
|
<td><?= $model["descrizione"] ?></td>
|
||||||
|
<td><?= $model["quantita"] ?></td>
|
||||||
|
<td><a href="index.php?cod=<?= $model["codice_modello"] ?>"><?= $model["nome"] ?></a></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function redirectToMarca(selectElement) {
|
||||||
|
const selectedMarca = selectElement.value;
|
||||||
|
if (selectedMarca) {
|
||||||
|
window.location.href = `index.php?cod=${encodeURIComponent(selectedMarca)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
</html>
|
221
orologi/admin/dashboard.php
Normal file
221
orologi/admin/dashboard.php
Normal file
|
@ -0,0 +1,221 @@
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
// Database connection details
|
||||||
|
$host = "192.168.1.20";
|
||||||
|
$database = "orologi";
|
||||||
|
$user = "pdo";
|
||||||
|
$password = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Establish a connection to the database
|
||||||
|
$connection = new PDO("mysql:host=$host;dbname=$database", $user, $password);
|
||||||
|
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Error: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle CRUD operations for Marche
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['action'])) {
|
||||||
|
$action = $_POST['action'];
|
||||||
|
|
||||||
|
if ($action == 'add_marca') {
|
||||||
|
$marca = $_POST['marca'];
|
||||||
|
$nazione = $_POST['nazione'];
|
||||||
|
$stmt = $connection->prepare("INSERT INTO marche (marca, nazione) VALUES (:marca, :nazione)");
|
||||||
|
$stmt->execute(['marca' => $marca, 'nazione' => $nazione]);
|
||||||
|
} elseif ($action == 'delete_marca') {
|
||||||
|
$marca = $_POST['marca'];
|
||||||
|
$stmt = $connection->prepare("DELETE FROM marche WHERE marca = :marca");
|
||||||
|
$stmt->execute(['marca' => $marca]);
|
||||||
|
} elseif ($action == 'update_marca') {
|
||||||
|
$marca = $_POST['marca'];
|
||||||
|
$nazione = $_POST['nazione'];
|
||||||
|
$stmt = $connection->prepare("UPDATE marche SET nazione = :nazione WHERE marca = :marca");
|
||||||
|
$stmt->execute(['marca' => $marca, 'nazione' => $nazione]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect to avoid form resubmission
|
||||||
|
header("Location: dashboard.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle CRUD operations for Orologi
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['action'])) {
|
||||||
|
$action = $_POST['action'];
|
||||||
|
|
||||||
|
// Handle Marche operations
|
||||||
|
if ($action == 'add_marca') {
|
||||||
|
$marca = $_POST['marca'];
|
||||||
|
$nazione = $_POST['nazione'];
|
||||||
|
$stmt = $connection->prepare("INSERT INTO marche (marca, nazione) VALUES (:marca, :nazione)");
|
||||||
|
$stmt->execute(['marca' => $marca, 'nazione' => $nazione]);
|
||||||
|
} elseif ($action == 'delete_marca') {
|
||||||
|
$marca = $_POST['marca'];
|
||||||
|
$stmt = $connection->prepare("DELETE FROM marche WHERE marca = :marca");
|
||||||
|
$stmt->execute(['marca' => $marca]);
|
||||||
|
} elseif ($action == 'update_marca') {
|
||||||
|
$marca = $_POST['marca'];
|
||||||
|
$nazione = $_POST['nazione'];
|
||||||
|
$stmt = $connection->prepare("UPDATE marche SET nazione = :nazione WHERE marca = :marca");
|
||||||
|
$stmt->execute(['marca' => $marca, 'nazione' => $nazione]);
|
||||||
|
}
|
||||||
|
// Handle Orologi operations
|
||||||
|
elseif ($action == 'add_orologio') {
|
||||||
|
try {
|
||||||
|
$marca = $_POST['marca'];
|
||||||
|
$modello = $_POST['modello'];
|
||||||
|
$prezzo = $_POST['prezzo'];
|
||||||
|
$descrizione = $_POST['descrizione'];
|
||||||
|
|
||||||
|
$checkMarca = $connection->prepare("SELECT marca FROM marche WHERE marca = :marca");
|
||||||
|
$checkMarca->execute(['marca' => $marca]);
|
||||||
|
if (!$checkMarca->fetch()) {
|
||||||
|
echo "Error: Brand does not exist in marche table";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
echo
|
||||||
|
$stmt = $connection->prepare("INSERT INTO orologi (Marca, Modello, Prezzo, Descrizione) VALUES (:marca, :modello, :prezzo, :descrizione)");
|
||||||
|
$stmt->execute(['marca' => $marca, 'modello' => $modello, 'prezzo' => $prezzo, 'descrizione' => $descrizione]);
|
||||||
|
|
||||||
|
if ($stmt->rowCount() > 0) {
|
||||||
|
echo "Insert successful";
|
||||||
|
} else {
|
||||||
|
echo "Insert failed";
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo "Error: " . $e->getMessage();
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
} elseif ($action == 'delete_orologio') {
|
||||||
|
$codice = $_POST['codice'];
|
||||||
|
$stmt = $connection->prepare("DELETE FROM orologi WHERE Codice = :codice");
|
||||||
|
$stmt->execute(['codice' => $codice]);
|
||||||
|
} elseif ($action == 'update_orologio') {
|
||||||
|
$codice = $_POST['codice'];
|
||||||
|
$marca = $_POST['marca'];
|
||||||
|
$modello = $_POST['modello'];
|
||||||
|
$prezzo = $_POST['prezzo'];
|
||||||
|
$descrizione = $_POST['descrizione'];
|
||||||
|
$stmt = $connection->prepare("UPDATE orologi SET Marca = :marca, Modello = :modello, Prezzo = :prezzo, Descrizione = :descrizione WHERE Codice = :codice");
|
||||||
|
$stmt->execute(['codice' => $codice, 'marca' => $marca, 'modello' => $modello, 'prezzo' => $prezzo, 'descrizione' => $descrizione]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Single redirect after all operations
|
||||||
|
header("Location: dashboard.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch all Marche and Orologi
|
||||||
|
$marche = $connection->query("SELECT * FROM marche")->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$orologi = $connection->query("SELECT * FROM orologi")->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Admin Dashboard</title>
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@2/css/pico.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="container">
|
||||||
|
<h1>Admin Dashboard</h1>
|
||||||
|
<a href="logout.php" class="button">Logout</a>
|
||||||
|
|
||||||
|
<!-- Marche Section -->
|
||||||
|
<h2>Marche</h2>
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="action" value="add_marca">
|
||||||
|
<label for="marca">Marca:</label>
|
||||||
|
<input type="text" id="marca" name="marca" required>
|
||||||
|
<label for="nazione">Nazione:</label>
|
||||||
|
<input type="text" id="nazione" name="nazione" required>
|
||||||
|
<button type="submit">Add Marca</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Marca</th>
|
||||||
|
<th>Nazione</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($marche as $marca): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($marca['marca']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($marca['nazione']); ?></td>
|
||||||
|
<td>
|
||||||
|
<form method="post" style="display:inline;">
|
||||||
|
<input type="hidden" name="action" value="delete_marca">
|
||||||
|
<input type="hidden" name="marca" value="<?php echo $marca['marca']; ?>">
|
||||||
|
<button type="submit">Delete</button>
|
||||||
|
</form>
|
||||||
|
<form method="post" style="display:inline;">
|
||||||
|
<input type="hidden" name="action" value="update_marca">
|
||||||
|
<input type="hidden" name="marca" value="<?php echo $marca['marca']; ?>">
|
||||||
|
<input type="text" name="nazione" placeholder="New Nazione" required>
|
||||||
|
<button type="submit">Update</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- Orologi Section -->
|
||||||
|
<h2>Orologi</h2>
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="action" value="add_orologio">
|
||||||
|
<label for="marca">Marca:</label>
|
||||||
|
<select id="marca" name="marca" required>
|
||||||
|
<?php foreach ($marche as $marca): ?>
|
||||||
|
<option value="<?php echo $marca['marca']; ?>"><?php echo $marca['marca']; ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
<label for="modello">Modello:</label>
|
||||||
|
<input type="text" id="modello" name="modello" required>
|
||||||
|
<label for="prezzo">Prezzo:</label>
|
||||||
|
<input type="number" id="prezzo" name="prezzo" required>
|
||||||
|
<label for="descrizione">Descrizione:</label>
|
||||||
|
<textarea id="descrizione" name="descrizione" required></textarea>
|
||||||
|
<button type="submit">Add Orologio</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Codice</th>
|
||||||
|
<th>Marca</th>
|
||||||
|
<th>Modello</th>
|
||||||
|
<th>Prezzo</th>
|
||||||
|
<th>Descrizione</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($orologi as $orologio): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($orologio['Codice']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($orologio['Marca']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($orologio['Modello']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($orologio['Prezzo']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($orologio['Descrizione']); ?></td>
|
||||||
|
<td>
|
||||||
|
<form method="post" style="display:inline;">
|
||||||
|
<input type="hidden" name="action" value="delete_orologio">
|
||||||
|
<input type="hidden" name="codice" value="<?php echo $orologio['Codice']; ?>">
|
||||||
|
<button type="submit">Delete</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
77
orologi/admin/login.php
Normal file
77
orologi/admin/login.php
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
// Database connection details
|
||||||
|
$host = "192.168.1.20";
|
||||||
|
$database = "orologi";
|
||||||
|
$user = "pdo";
|
||||||
|
$password = "";
|
||||||
|
|
||||||
|
// Initialize error message
|
||||||
|
$error = '';
|
||||||
|
|
||||||
|
// Check if the form is submitted
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
try {
|
||||||
|
// Establish a connection to the database
|
||||||
|
$connection = new PDO("mysql:host=$host;dbname=$database", $user, $password);
|
||||||
|
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
|
||||||
|
// Get the username and password from the form
|
||||||
|
$username = $_POST['username'];
|
||||||
|
$password = $_POST['password'];
|
||||||
|
|
||||||
|
// Prepare the SQL statement to fetch the user
|
||||||
|
$stmt = $connection->prepare("SELECT * FROM utenti WHERE user = :username");
|
||||||
|
$stmt->execute(['username' => $username]);
|
||||||
|
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
// Verify the password
|
||||||
|
if ($user && $user['password'] === $password) {
|
||||||
|
// Password is correct, start a new session
|
||||||
|
$_SESSION['user_id'] = $user['idut'];
|
||||||
|
$_SESSION['username'] = $user['user'];
|
||||||
|
$_SESSION['livello'] = $user['livello'];
|
||||||
|
$_SESSION["login"] = true;
|
||||||
|
|
||||||
|
// Redirect to a different page after successful login
|
||||||
|
header("Location: index.php");
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
// Invalid credentials
|
||||||
|
$error = "Invalid username or password.";
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$error = "Error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Login</title>
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@2/css/pico.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="container">
|
||||||
|
<h1>Login</h1>
|
||||||
|
<?php if ($error): ?>
|
||||||
|
<div class="alert alert-danger"><?php echo $error; ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<form method="post" action="">
|
||||||
|
<label for="username">Username:</label>
|
||||||
|
<input <?php if ($error):
|
||||||
|
echo "aria-invalid=\"true\""; endif; ?> type="text" id="username" name="username" required>
|
||||||
|
|
||||||
|
<label for="password">Password:</label>
|
||||||
|
<input <?php if ($error):
|
||||||
|
echo "aria-invalid=\"true\""; endif; ?> type="password" id="password" name="password" required>
|
||||||
|
|
||||||
|
<button type="submit">Login</button>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
59
orologi/dettagli.php
Normal file
59
orologi/dettagli.php
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
|
$host = "192.168.1.20";
|
||||||
|
$database = "orologi";
|
||||||
|
$user = "pdo";
|
||||||
|
$password = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$connection = new PDO("mysql:host=$host;dbname=$database", $user, $password);
|
||||||
|
|
||||||
|
$prepare = $connection->prepare("SELECT * FROM orologi WHERE Codice = ?");
|
||||||
|
$prepare->bindValue(1, $_GET["cod"], PDO::PARAM_INT);
|
||||||
|
$prepare->execute();
|
||||||
|
|
||||||
|
if ($prepare->rowCount() == 0) {
|
||||||
|
die("Non trovato");
|
||||||
|
}
|
||||||
|
$connection = null;
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die ("Error!: " . $e->getMessage() . "<br/>");
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>HTML</title>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
||||||
|
>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<main class="container">
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Acme Corp</strong></li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li><a href="index.php">Home</a></li>
|
||||||
|
<li><a href="#">Login</a></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<?php foreach ($prepare->fetchAll() as $row) : ?>
|
||||||
|
<h1><?= $row["Marca"] . " " . $row["Modello"] ?></h1>
|
||||||
|
<h2>Descrizione</h2>
|
||||||
|
<p><?= $row["Descrizione"] ?></p>
|
||||||
|
<h2>Prezzo: <?= $row["Prezzo"] ?> €</h2>
|
||||||
|
<p><small>(Codice Orologio: <?= $row["Codice"] ?>)</p>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
96
orologi/index.php
Normal file
96
orologi/index.php
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
|
$host = "192.168.1.20";
|
||||||
|
$database = "orologi";
|
||||||
|
$user = "pdo";
|
||||||
|
$password = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$connection = new PDO("mysql:host=$host;dbname=$database", $user, $password);
|
||||||
|
$marche = $connection->prepare("SELECT marca FROM marche");
|
||||||
|
$marche->execute();
|
||||||
|
|
||||||
|
if (empty($_GET["marca"])) {
|
||||||
|
$prepare = $connection->prepare("SELECT Codice, Modello, Marca, Prezzo FROM orologi ORDER BY Marca");
|
||||||
|
} else {
|
||||||
|
$marca = $_GET["marca"];
|
||||||
|
$prepare = $connection->prepare("SELECT Codice, Modello, Marca, Prezzo FROM orologi WHERE Marca = ? ORDER BY Marca");
|
||||||
|
$prepare->bindParam(1, $marca);
|
||||||
|
}
|
||||||
|
|
||||||
|
$prepare->execute();
|
||||||
|
|
||||||
|
$connection = null;
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die ("Error!: " . $e->getMessage() . "<br/>");
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>HTML</title>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
||||||
|
>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<main class="container">
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Acme Corp</strong></li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<form>
|
||||||
|
<select name="favorite-cuisine" aria-label="Cerca per Marca" required
|
||||||
|
onchange="redirectToMarca(this)">
|
||||||
|
<option selected disabled value="">
|
||||||
|
Cerca per Marca
|
||||||
|
</option>
|
||||||
|
<?php foreach ($marche->fetchAll() as $rw) : ?>
|
||||||
|
<option value=<?= $rw["marca"] ?>><?= $rw["marca"] ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#">Login</a></li>
|
||||||
|
<li><a href="index.php">Home</a></li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="grid">
|
||||||
|
<?php foreach ($prepare->fetchAll() as $row) : ?>
|
||||||
|
<?= "<div>" ?>
|
||||||
|
<article>
|
||||||
|
<header><a href=<?= "dettagli.php?cod=" . $row["Codice"] ?>><b><?= $row["Modello"] ?></b></a>
|
||||||
|
</header>
|
||||||
|
<?= $row["Marca"] ?>
|
||||||
|
<footer>Prezzo: <?= $row["Prezzo"] ?> €</footer>
|
||||||
|
</article>
|
||||||
|
<?= "</div>" ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function redirectToMarca(selectElement) {
|
||||||
|
const selectedMarca = selectElement.value;
|
||||||
|
if (selectedMarca) {
|
||||||
|
window.location.href = `index.php?marca=${encodeURIComponent(selectedMarca)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
</html>
|
48
pdo/elenco_squadre/index.php
Normal file
48
pdo/elenco_squadre/index.php
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
|
$host = "192.168.1.20";
|
||||||
|
$database = "tiro_piattello";
|
||||||
|
$user = "pdo";
|
||||||
|
$password = "";
|
||||||
|
|
||||||
|
$datiMedici = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
$connection = new PDO("mysql:host=$host;dbname=$database", $user, $password);
|
||||||
|
echo "Connected successfully<br>";
|
||||||
|
|
||||||
|
$prepare = $connection->prepare("SELECT id, nome, sede FROM squadra ORDER BY nome");
|
||||||
|
$prepare->execute();
|
||||||
|
if ($prepare->rowCount() > 0) {
|
||||||
|
$datiMedici = $prepare->fetchAll();
|
||||||
|
}
|
||||||
|
$connection = null;
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die ("Error!: " . $e->getMessage() . "<br/>");
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>HTML</title>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
||||||
|
>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<main class="container">
|
||||||
|
<h1>Lista squadra db</h1>
|
||||||
|
<?php foreach ($datiMedici as $med) {
|
||||||
|
echo "<h2>" . $med['nome'] . " </h2>";
|
||||||
|
} ?>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
Loading…
Add table
Reference in a new issue