yogibook-aury/public/process.php
2024-09-18 16:47:42 +02:00

56 lines
1.6 KiB
PHP

<?php
include('include/headscript.php');
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connessione fallita: " . $conn->connect_error);
}
if (isset($_POST['submit'])) {
$iduser = $_POST['iduser'];
$datebirth = $_POST['datebirth'];
$yogafor = $_POST['yogafor'];
$healthissue = $_POST['healthissue'];
$generalcomment = $_POST['generalcomment'];
$kind = $_POST['kind'];
if ($kind=='insert') {
// Inserimento dei dati nel database
$sql = "INSERT INTO userprofile (iduser, datebirth, yogafor, healthissue, generalcomment)
VALUES ('$iduser', '$datebirth', '$yogafor', '$healthissue', '$generalcomment')
ON DUPLICATE KEY UPDATE
datebirth = '$datebirth', yogafor = '$yogafor', healthissue = '$healthissue', generalcomment = '$generalcomment'";
if ($conn->query($sql) === TRUE) {
echo "Dati inseriti/aggiornati con successo.";
} else {
echo "Errore nell'esecuzione della query: " . $conn->error;
}
header("Location: userprofile.php?message=success");
exit();
} else {
// Update dei dati nel database
$sql = "UPDATE userprofile SET datebirth = '$datebirth', yogafor = '$yogafor', healthissue = '$healthissue', generalcomment = '$generalcomment'
WHERE iduser='$iduser'";
if ($conn->query($sql) === TRUE) {
echo "Dati inseriti/aggiornati con successo.";
} else {
echo "Errore nell'esecuzione della query: " . $conn->error;
}
header("Location: userprofile.php?message=success");
exit();
}
}
$conn->close();
?>