Implementazione registrazione e ruolo utente
This commit is contained in:
+5
-4
@@ -36,7 +36,8 @@ CREATE TABLE Utenti(
|
||||
nome VARCHAR(30),
|
||||
cognome VARCHAR(18),
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
password VARCHAR(255) NOT NULL
|
||||
password VARCHAR(255) NOT NULL,
|
||||
ruolo VARCHAR(16) DEFAULT 'utente'
|
||||
);
|
||||
|
||||
-- 3. INSERIMENTO DATI (INSERT INTO)
|
||||
@@ -78,6 +79,6 @@ INSERT INTO Statistiche_Social (id_fascia, piattaforma, minuti_medi_giornalieri,
|
||||
-- Login utente esempio
|
||||
-- Email: jeevacation@gmail.com
|
||||
-- Password: changeme
|
||||
INSERT INTO Utenti(nome,cognome,email,password) VALUES
|
||||
('Jeffrey', 'Epstein', 'jeevacation@gmail.com', '$2y$10$1ZILQ71xxMjaAxDs2A6/Iut8UJfBPEGkeEuZgoIkVDapbNYUACxtW'),
|
||||
('Andrea', 'Fiorencis', 'andrea@fiorencis.eu','$2y$10$y7fs8u4UOFJW5ds/dO84KumTxG2kh4jCubb1W0mAHzgmBZKRqA8Va');
|
||||
INSERT INTO Utenti(nome,cognome,email,password,ruolo) VALUES
|
||||
('Jeffrey', 'Epstein', 'jeevacation@gmail.com', '$2y$10$1ZILQ71xxMjaAxDs2A6/Iut8UJfBPEGkeEuZgoIkVDapbNYUACxtW', 'gestore'),
|
||||
('Andrea', 'Fiorencis', 'andrea@fiorencis.eu','$2y$10$y7fs8u4UOFJW5ds/dO84KumTxG2kh4jCubb1W0mAHzgmBZKRqA8Va', 'gestore');
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
include 'db_conf.php';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Registrazione - TechStore</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if($_POST['password'] !== $_POST['confirm_password']){
|
||||
echo "<p style='color: red; text-align: center;'>Le password non corrispondono.</p>";
|
||||
}
|
||||
else{
|
||||
$sql = "INSERT INTO Utenti (nome, cognome, email, password) VALUES (?, ?, ?, ?)";
|
||||
if($stmt = $conn->prepare($sql)){
|
||||
$stmt->bind_param("ssss", $name, $surname, $email, $password);
|
||||
|
||||
$name = $_POST['name'];
|
||||
$surname = $_POST['surname'];
|
||||
$email = $_POST['email'];
|
||||
$password = password_hash($_POST['password'], PASSWORD_BCRYPT);
|
||||
$stmt->execute();
|
||||
|
||||
echo "<p style='color: green; text-align: center;'>Registrazione avvenuta con successo! <a href=\"login.php\">Accedi</a></p>";
|
||||
}
|
||||
else{
|
||||
echo "Errore: " . $conn->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="" method="POST">
|
||||
<h2>Registrazione</h2>
|
||||
<label for="name">Nome:</label>
|
||||
<input type="text" id="name" name="name" required><br>
|
||||
<label for="surname">Cognome:</label>
|
||||
<input type="text" id="surname" name="surname" required><br>
|
||||
<label for="email">Indirizzo e-mail:</label>
|
||||
<input type="email" id="email" name="email" required><br>
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" id="password" name="password" required><br>
|
||||
<label for="confirm_password">Conferma password:</label>
|
||||
<input type="password" id="confirm_password" name="confirm_password" required><br><br>
|
||||
<input type="submit" value="Registrati">
|
||||
<p>Hai già un account? <a href="login.php">Accedi</a></p>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user