Codice PHP:
<center><h5>Modifica un iscritto</h5></center>
<?php
if(isset($_GET['edit'])){
$id = $_GET['edit'];
$query = "SELECT * FROM utenti WHERE id = $id";
$utenteUpdate = mysqli_query($connessione, $query);
while($row = mysqli_fetch_assoc($utenteUpdate)){
$id = $row['id'];
$nome = $row['nome'];
$cognome = $row['cognome'];
$email = $row['email'];
$password = $row['password'];
}
}
?>
<label for="nome">Nome *</label>
<input value='<?php if(isset($nome)){echo $nome;}?>' type="nome" id="nome" placeholder="Nome" name="nome" maxlength="50" >
<label for="cognome">Cognome *</label>
<input value='<?php if(isset($cognome)){echo $cognome;}?>' type="cognome" id="cognome" placeholder="Cognome" name="cognome" maxlength="50" >
<label for="cognome">Email *</label>
<input value='<?php if(isset($email)){echo $email;}?>' type="email" id="email" placeholder="Email" name="email" maxlength="50" >
<label for="cognome">Password *</label>
<input value='<?php if(isset($password)){echo $password;}?>' type="password" id="password" placeholder="Password" name="password" maxlength="50" >
<?php
if(isset($_POST['update'])){
$utenteAggiorna = $_POST['id'];
$query = "UPDATE utenti SET email '{$utenteAggiorna}' WHERE id = {$id}";
$utenteUp = mysqli_query($connessione, $query);
}
?>
<form method="POST">
<button type=”submit” id="update" name="update"> Aggiorna</button>
</form>