Salve a tutti,
Ho un sito in cui vorrei amministrare una parte attraverso un DB. Ho ripreso una cosa vecchia che avevo fatto anni fa ma purtroppo nn mi ricordo più certe cose.
Il mio DB in access è composto dai seguenti campi:
Attivita, Categoria, Indirizzo, Citta, Provincia, Email, Referente, Telefono, Fax, Cellulare
lL DB l'ho già fatto, la pagina per riempire i campi si chiama:
inserimento.asp
ed è la seguente:
************************************************** ***************
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento senza titolo</title>
</head>
<body>
<%
Dim Attivita, Categoria, Indirizzo, Citta, Provincia, Email, Referente, Telefono, Fax, Cellulare
Attivita = request.form("txtAttivita")
Categoria = request.form("cmbCategorie")
Indirizzo = request.form("txtIndirizzo")
Citta = request.form("txtCitta")
Provincia = request.form("cmbProvincia")
Email = request.form("txtEmail")
Referente = request.form("txtReferente")
Telefono = request.form("txtTelefono")
Fax = request.form("txtFax")
Cellulare = request.form("txtCellulare")
'********* CREAZIONE STRINGA DI VERIFICA
Dim sDefaultChars
Dim iCounter
Dim iPickedChar
Dim iDefaultCharactersLength
Dim iPasswordLength
'Inizializzo
sDefaultChars="ABCDEFGHIJKLMNOPQRSTUVXYZ0123456789 "
iPasswordLength=20
iDefaultCharactersLength = Len(sDefaultChars)
Randomize'Generazione Random
For iCounter = 1 To iPasswordLength
'Next pick a number from 1 to length of character set
iPickedChar = Int((iDefaultCharactersLength * Rnd) + 1)
'Next pick a character from the character set using the random number iPickedChar
'and Mid function
Check = Check & Mid(sDefaultChars,iPickedChar,1)
Next
'************************************************* *****************
' INSERIMENTO NEL DATABASE
'************************************************* *****************
Dim Conn
Dim rstPetizione
Dim strSQL
Set Conn = Server.CreateObject("ADODB.Connection")
%><%
Set rstPetizione = Server.CreateObject("ADODB.Recordset")
strSQL="SELECT Email FROM Generale WHERE eMail='" & eMail & "'"
rstPetizione.Open strSQL,Conn
if (rstPetizione.bof) AND (rstPetizione.eof) then
'******** INSERISCO NUOVA FIRMA NEL DATABASE
strSQL = "INSERT INTO Generale (Attivita, Categoria, Indirizzo, Citta, Provincia, Email, Referente, Telefono, Fax, Cellulare) VALUES ('" & Attivita & "', '" & Categoria & "', '" & Indirizzo & "', '" & Citta & "', '" & Provincia & "', '" & Email & "', '" & Referente & "', '" & Telefono & "', '" & Fax & "', '" & Cellulare & "', '" & now() & "')"
Conn.Execute(strSQL)
set rstPetizione = nothing
set Conn = nothing
%>
</body>
</html>
************************************************** *********
La pagina con il form di inserimento è:inserimento.htm
ed il contenuto togliendo la parte iniaziale altrimenti troppo lunga:
************************************************** *********
.................................................. ...................
<script type="text/javascript">
_uacct = "UA-173411-1";
urchinTracker();
</script>
<script language="JavaScript" type="text/javascript">
<!--
function checkform ( form )
{
// ** START **
if (form.txtNome.value == "") {
alert( "Il campo NOME non può essere vuoto" );
form.txtNome.focus();
return false ;
}
if (form.txtCognome.value == "") {
alert( "Il campo COGNOME non può essere vuoto" );
form.txtCognome.focus();
return false ;
}
if (form.txtCitta.value == "") {
alert( "Il campo CITTA' non può essere vuoto" );
form.txtCitta.focus();
return false ;
}
if (form.cmbProvincia.value == "X") {
alert( "Selezionare la PROVINCIA" );
form.cmbProvincia.focus();
return false ;
}
if (form.txtEmail.value == "") {
alert( "Il campo E-Mail non può essere vuoto" );
form.txtEmail.focus();
return false ;
}
// ** END **
return true ;
}
//-->
</script>
<style type="text/css">
<!--
@import url(CSS/terminecss.css);
.style1 {font-family: Tahoma; font-size: 12; color: Navy;}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body onLoad="textticker()">
<form action="inserimento.asp" method="post" name="inserimento" onSubmit="return checkform(this);">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><table width="75%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="33%" class="TestoForm">Attivita</td>
<td width="67%"><input name="txtAttivita" type="text" size="60" maxlength="50" tabindex="0"></td>
</tr>
<tr>
<td class="TestoForm">Categoria :</td>
<td><select name="cmbCategoria" tabindex="4">
<option value="X" selected> --</option>
<option value="Abbigliamento">Abbigliamento</option>
<option value="Artigianato">Artigianato</option>
<option value="Bioedilizia">Bioedilizia</option>
<option value="Camapagne">Camapagne</option>
<option value="Centri">Centri</option>
<option value="Cooperative">Cooperative</option>
<option value="Erboristerie">Erboristerie</option>
<option value="Eventi">Eventi</option>
<option value="Gas">Gas</option>
<option value="Librerie">Librerie</option>
<option value="Negozi">Negozi</option>
<option value="Produttori">Produttori</option>
<option value="Ristoranti">Ristoranti</option>
<option value="Turismo">Turismo</option>
<option value="Vendita">Vendita</option>
</select> </td>
</tr>
<tr>
<td class="TestoForm">Indirizzo : </td>
<td><input name="txtIndirizzo" type="text" tabindex="2" size="60" maxlength="60"></td>
</tr>
<tr>
<td class="TestoForm">Città : </td>
<td><input name="txtCitta" type="text" tabindex="3" size="60" maxlength="50"></td>
</tr>
<tr>
<td class="TestoForm">Provincia : </td>
<td><select name="cmbProvincia" tabindex="4">
<option value="X" selected> --</option>
<option value="EE">EE</option>
............
...........
</select> </td>
</tr>
<tr>
<td class="TestoForm">Indirizzo E-mail : </td>
<td><input name="txtEmail" type="text" tabindex="7" size="60" maxlength="60"></td>
</tr>
<tr>
<td class="TestoForm">Referente : </td>
<td><input name="txtReferente" type="text" tabindex="7" size="60" maxlength="60"></td>
</tr>
<tr>
<td class="TestoForm">Telefono : </td>
<td><input name="txtTelefono" type="text" tabindex="7" size="60" maxlength="60"></td>
</tr>
<tr>
<td class="TestoForm">Fax : </td>
<td><input name="txtFax" type="text" tabindex="7" size="60" maxlength="60"></td>
</tr>
<tr>
<td class="TestoForm">Cellulare : </td>
<td><input name="txtCellulare" type="text" tabindex="7" size="60" maxlength="60"></td>
</tr>
<tr>
<td colspan="2" align="center"></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="btnInvia" type="submit" class="Bottone" tabindex="8" value="inserimento"></td>
</tr>
<tr>
<td colspan="2" align="center"></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
************************************************** ******
Ovviamente ci saranno degli errori, anche grossi, quando provo ad inserire i contenuti nel data base mi dice:
"
"Microsoft VBScript compilation error '800a03f6'
Expected 'End'
/inserimento.asp, line 63
Se qualcuno mi può dire dove sbaglio mi farebbe un piacere....sono bloccato da qualche giorno
Grazie MArco

Rispondi quotando
