questo è il form:
Codice HTML:
<form method="post" action="invio.php">
Nome:<input type="text" name="nome"><br>
Cognome:<input type="text" name="cognome"><br>
<input type="submit" value=" Invio ">
</form>
Codice PHP:
<?php
$dbhost = "localhost";
$dbuser = "skaz88";
$dbpass = "";
$dbname = "my_skaz88".$db_user;
$db = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $db);
mysql_query("INSERT INTO fede (nome,cognome) VALUES(\"".$_POST['nome']."\",\"".$_POST['cognome']."\")");
mysql_close($db);
?>
tabella:
Codice PHP:
$sql = 'CREATE TABLE `fede` ('
. ' `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, '
. ' `nome` VARCHAR(20) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL, '
. ' `cognome` VARCHAR(20) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,'
. ' INDEX (`id`)'
. ' )'
. ' ENGINE = myisam'
. ' CHARACTER SET latin1 COLLATE latin1_general_cs;';