Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Nuovo Alunno</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Geany 0.18" />
</head>
<body>
<?php
print("Nuovo alunno");
$host1=fopen("host.txt","r");
$host2=fread($host1,filesize("host.txt"));
$user1=fopen("user.txt","r");
$user2=fread($user1,filesize("user.txt"));
$pwd1=fopen("pwd.txt","r");
$pwd2=fread($pwd1,filesize("pwd.txt"));
$db1=fopen("db.txt","r");
$db2=fread($db1,filesize("db.txt"));
$host = $host2;
$user = $user2;
$password = $pwd2;
$database = $db2;
$db = mysql_connect($host, $user, $password) or die ("Impossibile connettersi al server $host");
mysql_select_db($database, $db) or die ("Impossibile connettersi al database $database");
$query = "insert into alunni " .
"(nome, cognome, sesso, cittadinanza, residenza, trasporti, as_di_riferimento, data_di_iscrizione, frequenza, provenienza, trasferimenti, codice_fiscale, luogo_data_nascita, city, street, home_phone, mobile_phone, another_phone, e-mail, father_name, father_surname, father_born, father_title, father_job, father_live, father_home_phone, father_mobile_phone, father_work_phone, mother_name, mother_surname, mother_born, mother_title, mother_job, mother_live, mother_home_phone, mother_mobile_phone, mother_work_phone, tutor_name, tutor_born, tutor_title_job, tutor_phone) " .
"VALUES('" .
$_REQUEST['nome'] . "','" .
$_REQUEST['cognome'] . "','" .
$_REQUEST['sesso'] . "','" .
$_REQUEST['cittadinanza'] . "','" .
$_REQUEST['residenza'] . "','" .
$_REQUEST['trasporti'] . "','" .
$_REQUEST['as_di_riferimento'] . "','" .
$_REQUEST['data_di_iscrizione'] . "','" .
$_REQUEST['frequenza'] . "','" .
$_REQUEST['provenienza'] . "','" .
$_REQUEST['trasferimenti'] . "','" .
$_REQUEST['codice_fiscale'] . "','" .
$_REQUEST['luogo_data_nascita'] . "','" .
$_REQUEST['city'] . "','" .
$_REQUEST['street'] . "','" .
$_REQUEST['home_phone'] . "','" .
$_REQUEST['mobile_phone'] . "','" .
$_REQUEST['another_phone'] . "','" .
$_REQUEST['e-mail'] . "','" .
$_REQUEST['father_name'] . "','" .
$_REQUEST['father_surname'] . "','" .
$_REQUEST['father_born'] . "','" .
$_REQUEST['father_title'] . "','" .
$_REQUEST['father_job'] . "','" .
$_REQUEST['father_live'] . "','" .
$_REQUEST['father_home_phone'] . "','" .
$_REQUEST['father_mobile_phone'] . "','" .
$_REQUEST['father_work_phone'] . "','" .
$_REQUEST['mother_name'] . "','" .
$_REQUEST['mother_surname'] . "','" .
$_REQUEST['mother_born'] . "','" .
$_REQUEST['mother_title'] . "','" .
$_REQUEST['mother_job'] . "','" .
$_REQUEST['mother_live'] . "','" .
$_REQUEST['mother_home_phone'] . "','" .
$_REQUEST['mother_mobile_phone'] . "','" .
$_REQUEST['mother_work_phone'] . "','" .
$_REQUEST['tutor_name'] . "','" .
$_REQUEST['tutor_surname'] . "','" .
$_REQUEST['tutor_born'] . "','" .
$_REQUEST['tutor_title_job'] . "','" .
$_REQUEST['tutor_phone'] . "')";
if (!mysql_query($query, $db))
{
print("Impossibile inserire il record");
}
else
{
print("Record inserito!");
}
mysql_close($db);
?>
</body>
</html>