PDA

View Full Version : Aiuto!


Simox-2001
30-01-2020, 07:58
Ciao a tutti, č da giorni che provo diverse modifiche al codice ma nessuna funziona; vorrei che il codice .php andasse ad inserire i dati nella tabella del database (phpMyAdmin) prendendo i dati da un form .html,qualcuno puņ aiutarmi?

I codici:

<?php

$host= 'localhost';
$user= 'user';
$password= 'pw';
$database= 'nome';

mysql_connect($host, $user, $password)
or die('Errore durante la connessione:' .mysql_error());

mysql_select_db($database)
or die ('Errore durante la selezione del database:' .mysql_error());

$sql = "INSERT INTO 'tabella1' ('ID', 'Username', 'E-mail', 'Password') VALUES (NULL, '$username', '$email', '$password')";
if (mysql_query($sql)) {
echo "Dati aggiunti correttamente al database";
} else {
echo "Errore di inserimento:" .mysql_error();
}

mysql_close();

?>

<!DOCTYPE html>

<html>
<head>
<title>DB FORM PROVA 1</title>
</head>

<body>

<form method="POST" action="DB php.php">
Username:
<input type="text" name="username" >
<br>
<br>
E-mail:
<input type="text" name="e-mail" >
<br>
<br>
Password:
<input type="text" name="password" >
<br>
<br>
<input type="submit" name="submit" value="Invia i dati">
</form>

</body>
</html>

I permessi su su phpMyAdmin sono tutti dati e uso XAMPP.


Inviato dal mio iPhone utilizzando Tapatalk

FreeMan
30-01-2020, 20:15
Titolo discussione non esplicativo... se tutti aprissero thread intitolati "aiuto" "vi prego aiutatemi" ecc il forum sarebbe illeggibile oltre che assomigliare ad un nosocomio.

CLOSED!!

>bYeZ<