46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php include('include/headscript.php'); ?>
|
|
<?php
|
|
// Includi il file di connessione al database
|
|
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
// Recupera i dati inviati tramite AJAX
|
|
$user_id = $_POST['user_id'];
|
|
$first_name = $_POST['first_name'];
|
|
$last_name = $_POST['last_name'];
|
|
$address = $_POST['address'];
|
|
$zip = $_POST['zip'];
|
|
$city = $_POST['city'];
|
|
$country_id = $_POST['country_id'];
|
|
$phone = $_POST['phone'];
|
|
$fiscalcode = $_POST['fiscalcode'];
|
|
|
|
$conn = new mysqli($servername, $username, $password, $database);
|
|
// Crea la query per aggiornare l'utente, escludendo l'email
|
|
$sql = "UPDATE auth_users SET
|
|
first_name = ?,
|
|
last_name = ?,
|
|
address = ?,
|
|
zip = ?,
|
|
city = ?,
|
|
country_id = ?,
|
|
phone = ?,
|
|
fiscalcode = ?
|
|
WHERE id = ?";
|
|
|
|
// Prepara e lega i parametri
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->bind_param("ssssssssi", $first_name, $last_name, $address, $zip, $city, $country_id, $phone, $fiscalcode, $user_id);
|
|
|
|
// Esegui la query
|
|
if ($stmt->execute()) {
|
|
echo "Dati aggiornati con successo";
|
|
} else {
|
|
echo "Errore: " . $conn->error;
|
|
}
|
|
|
|
// Chiudi la connessione
|
|
$stmt->close();
|
|
$conn->close();
|
|
}
|