PDA

View Full Version : [PHP / MYSQL] passare i dati di un form


Dbz
17-07-2022, 10:43
HTML
<form action = "asd.php" method="POST">
<label for ="registrazione" > Registrati </label>
<input class = "button" type = "text" name = "nome1" >
<input class = "button" type = "text" name = "cognome1" >
<input class = "button" type = "text" name = "email1" >
<input class = "button" type ="submit" name = "submit" value ="registrati" > <br>

</form>


PHP
<?php
//collegamento al database //
$connessione = mysqli_connect(//////////////////////////////////////////////////////// DATI SENSIBILI);
$nome = $_POST["nome1"];
$cognome = $_POST["cognome1"];
$email = $_POST["email1"];

if($connessione == true){
echo "ti sei collegato al database <br>";
}
else{
echo "problema in fase di connessione <br>";
}

$sql = "INSERT INTO utenti (nome, cognome, email) VALUES
('{$nome}', '{$cognome}', '{$email}')";

if (mysqli_query($connessione, $sql) === true) {
echo "anagrafica creata";
}
else{
echo "problema creazione anagrafica";
}

mysqli_close($connessione);


?>

Il codice non funziona :muro: :muro: :muro:

Dbz
17-07-2022, 17:19
problema risolto: non avevo chiuso un tag nel codice html.