Scusate il ritardo, ma ieri sera ho "abbandonato" per ... sonno.
Però, se avete ancora abbastanza pazienza per aiutarmi, mando il codice di "nuovo.asp"
codice:
<%@LANGUAGE = JScript%>
<%
var azione= new String(Request.QueryString("azione"));
%>
<html>
<head>
</head>
<body>
<table align="center" width="90%" cellpadding="1" cellspacing="0" border="1">
<script Language="JavaScript" Type="text/javascript"><!--
function FrontPage_Form1_Validator(theForm)
{
if (theForm.nome.value == "")
{
alert("Inserire un valore per il campo \"nome\".");
theForm.nome.focus();
return (false);
}
if (theForm.nome.value.length > 255)
{
alert("Inserire al massimo 255 caratteri nel campo \"nome\".");
theForm.nome.focus();
return (false);
}
if (theForm.cognome.value == "")
{
alert("Inserire un valore per il campo \"cognome\".");
theForm.cognome.focus();
return (false);
}
if (theForm.cognome.value.length > 255)
{
alert("Inserire al massimo 255 caratteri nel campo \"cognome\".");
theForm.cognome.focus();
return (false);
}
if (theForm.cap.value == "")
{
alert("Inserire un valore per il campo \"cap\".");
theForm.cap.focus();
return (false);
}
if (theForm.cap.value.length > 5)
{
alert("Inserire al massimo 5 caratteri nel campo \"cap\".");
theForm.cap.focus();
return (false);
}
if (theForm.citta.value == "")
{
alert("Inserire un valore per il campo \"citta\".");
theForm.citta.focus();
return (false);
}
if (theForm.citta.value.length > 255)
{
alert("Inserire al massimo 255 caratteri nel campo \"citta\".");
theForm.citta.focus();
return (false);
}
if (theForm.indirizzo.value == "")
{
alert("Inserire un valore per il campo \"indirizzo\".");
theForm.indirizzo.focus();
return (false);
}
if (theForm.indirizzo.value.length > 255)
{
alert("Inserire al massimo 255 caratteri nel campo \"indirizzo\".");
theForm.indirizzo.focus();
return (false);
}
if (theForm.email.value == "")
{
alert("Inserire un valore per il campo \"email\".");
theForm.email.focus();
return (false);
}
if (theForm.email.value.length > 255)
{
alert("Inserire al massimo 255 caratteri nel campo \"email\".");
theForm.email.focus();
return (false);
}
if (theForm.password.value == "")
{
alert("Inserire un valore per il campo \"password\".");
theForm.password.focus();
return (false);
}
if (theForm.password.value.length < 3)
{
alert("Inserire almeno 3 caratteri nel campo \"password\".");
theForm.password.focus();
return (false);
}
if (theForm.password.value.length > 15)
{
alert("Inserire al massimo 15 caratteri nel campo \"password\".");
theForm.password.focus();
return (false);
}
if (theForm.password1.value != theForm.password.value)
{
alert("Password di conferma errata, ridigitare prego.");
theForm.password1.value = ("");
theForm.password1.focus();
return (false);
}
return (true);
}
//--></script><form method="POST" action="inserisci.asp?azione=ADD" onsubmit="return FrontPage_Form1_Validator(this)" name="FrontPage_Form1" language="JavaScript">
<tr>
<td colspan="4" align="center">Inserisci i tuoi dati </td>
</tr>
<tr>
<td width="50%" colspan="2">Nome*<input type="text" name="nome" maxlength="255" style="width: 100%;" size="20"></td>
<td width="50%" colspan="2">Cognome*<input type="text" name="cognome" maxlength="255" style="width: 100%;" size="20"></td>
</tr>
<tr>
<td colspan="1">Cap*<input type="text" name="cap" maxlength="5" style="width: 100%;" size="20"></td>
<td colspan="1">Città*<input type="text" name="citta" maxlength="255" style="width: 100%;" size="20"></td>
<td colspan="2">Indirizzo*<input type="text" name="indirizzo" maxlength="255" style="width: 100%;" size="20"></td>
</tr>
<tr>
<td width="25%" colspan="1" align="center">Sesso
<select name="sesso">
<option value="M">M</option>
<option value="F">F</option>
</select>
</td>
<td width="25%" colspan="1">Telefono<input type="text" name="telefono" maxlength="255" style="width: 100%;" size="20"></td>
<td width="50%" colspan="2">E-mail*<input type="text" name="email" maxlength="255" style="width: 100%;" size="20" value="@"></td>
</tr>
<tr>
<td width="50%" colspan="2">Password* (min. 3 - max. 15 caratteri alfanumerici)<input type="password" name="password" maxlength="15" style="width: 100%;" size="20"></td>
<td width="50%" colspan="2">Conferma password*<input type="password" name="password1" maxlength="15" style="width: 100%;" size="20"></td>
</tr>
<tr>
<td colspan="4" align="right"><input type="submit" value="Registra"></td>
</tr>
</form>
</table>
<%
if (azione== "ADD")
{
var nome = new String(Request.Form("nome"));
var cognome = new String(Request.Form("cognome"));
var email= new String(Request.Form("email"));
var password= new String(Request.Form("password"));
var indirizzo = new String(Request.Form("indirizzo"));
var cap = new String(Request.Form("cap"));
var citta = new String(Request.Form("citta"));
var telefono = new String(Request.Form("telefono"));
var sesso = new String(Request.Form("sesso"));
var livello = 1;
if (nome == "" || cognome == "")
{
Response.Redirect("nuovo.asp");
}
else
{
var Rs = new ActiveXObject("ADODB.Recordset");
Rs.Open("anagrafe",Cn,3,3);
Rs.AddNew();
Rs("nome") = nome;
Rs("cognome") = cognome;
Rs("email") = email;
Rs("indirizzo") = indirizzo;
Rs("cap") = cap;
Rs("citta") = citta;
Rs("telefono") = telefono;
Rs("sesso") = sesso;
Rs("livello") = livello;
Rs.Update();
Rs.Close();
Cn.Close();
Response.Write("<p align=\"center\">Inserimento effettuato!</p>");
}
}
%>
</body>
</html>
Ci sono 4 include in "nuovo.asp" (config_nuovo.inc, style.inc, header.inc e footer.inc) però penso che l'unico che potrebbe dare problemi è config_nuovo.inc il cui codice è:
codice:
<%
Response.Buffer = true;
var Cn = new ActiveXObject("ADODB.Connection");
Cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("database.mdb"));
%>
"style.inc" è un foglio di stile, gli altri due l'intestazione ed il piè di pagina che sono fissi per tutti i files. Fammi sapere se devo mandare anche questi.
Ciao, e grazie di nuovo.