56 lines
2.1 KiB
PHP
56 lines
2.1 KiB
PHP
<?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>
|