Sto creando una pagina per iscriversi sul sito, tramite un form da compilare che successivamente porta ad una pagina ASP che aggiunge i dati al database.
Questo è form:
<form method="post" action="fine_iscrizione.asp">
<table font style="font-family:Arial, Helvetica, sans-serif;color:#eaa114;font-size:12px" width="500">
<tr>
<td align="left">Nome:</td>
<td align="right"><input type="text" name="nome" size="20" maxlength="20"></td>
</tr>
<tr>
<td align="left">Cognome:</td>
<td align="right"><input type="text" name="cognome" size="20" maxlength="20"></td>
</tr>
<tr>
<td align="left">Codice Fiscale:</td>
<td align="right"><input type="text" name="cod_fisc" size="16" maxlength="16"></td>
</tr>
<tr>
<td align="left">Indirizzo:</td>
<td align="right"><input type="text" name="indirizzo" size="40" maxlength="40"></td>
</tr>
<tr>
<td align="left">Città:</td>
<td align="right"><input type="text" name="citta" size="30" maxlength="30"></td>
</tr>
<tr>
<td align="left">CAP:</td>
<td align="right"><input type="text" name="cap" size="5" maxlength="5"></td>
</tr>
<tr>
<td align="left">Telefono:</td>
<td align="right"><input type="text" name="telefono" size="11" maxlength="11"></td>
</tr>
<tr>
<td align="left">Username:</td>
<td align="right"><input type="text" name="username" size="15" maxlength="15"></td>
</tr>
<tr>
<td align="left">Password:</td>
<td align="right"><input type="password" name="password" size="8" maxlength="8"></td>
</tr>
<tr>
<td align="left">E-Mail:</td>
<td align="right"><input type="text" name="e_mail" size="50" maxlength="50"></td>
</tr>
</table>
<input type="submit" value="Conferma" name="conferma"><input type="reset" value="Annulla" name="annulla">
</form>
E questo è l'ASP della pagina collegata:
Come errore mi dice:
<%
' Declaring variables
Dim nome, cognome, cod_fisc, indirizzo, citta, cap, telefono, username, password, email, data_source, con, sql_insert
' A Function to check if some field entered by user is empty
Function ChkString(string)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
nome = ChkString(Request.Form("nome"))
cognome = ChkString(Request.Form("cognome"))
cod_fisc = ChkString(Request.Form("cod_fisc"))
indirizzo = ChkString(Request.Form("indirizzo"))
citta = ChkString(Request.Form("citta"))
cap = ChkString(Request.Form("cap"))
telefono = ChkString(Request.Form("telefono"))
username = ChkString(Request.Form("username"))
password = ChkString(Request.Form("password"))
email = ChkString(Request.Form("email"))
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("database.mdb")
sql_insert = "insert into tUtenti (Nome, Cognome, CodiceFiscale, Indirizzo, Citta, CAP, Telefono, Username, Password, E-Mail) values ('" & nome & "', '" & cognome & "', '" & cod_fisc & "', '" & indirizzo "', '" & citta & "', '" & cap & "', '" & telefono & "', '" & username & "', '" & password & "', '" & email & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute sql_insert
' Done. Close the connection
con.Close
Set con = Nothing
%>
Errore di compilazione di Microsoft VBScript error '800a0401'
Prevista fine istruzione
/sito/fine_iscrizione.asp, riga 68
sql_insert = "insert into tUtenti (Nome, Cognome, CodiceFiscale, Indirizzo, Citta, CAP, Telefono, Username, Password, E-Mail) values ('" & nome & "', '" & cognome & "', '" & cod_fisc & "', '" & indirizzo "', '" & citta & "', '" & cap & "', '" & telefono & "', '" & username & "', '" & password & "', '" & email & "')"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^
Cosa c'è di sbagliato?
Ho scritto male i dati nell'into?
I dati dovrebbero andare nel file database.mdb, nella tabella tUtenti e riempire i campi Nome, Cognome, CodiceFiscale, Indirizzo, Citta, CAP, Telefono, Username, Password, E-Mail.