no, devi fare una ricerca, mica mettere la parola SELECT così a muzzo. mai aperto un recordset? "SELECT colonna FROM tabella" tanto per intenderci
no, devi fare una ricerca, mica mettere la parola SELECT così a muzzo. mai aperto un recordset? "SELECT colonna FROM tabella" tanto per intenderci
CONTROLLA INNANZITUTTO SE TUTTI I CAMPI SONO STATI COMPILATI CORRETTAMENTE
IF username <> "" and password <> "" and Instr(email, "@") > 0 and Instr(email,".") > 0 then
Se tutti i campi sono corretti gli dai il percorso del database
url_DB = ???
Set Conn = Server.CreateObject("ADODB.Connection")
conn.Open url_DB
Set RecSet = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM TABELLA_UTENTI where username = '" & username &"'"
RecSet.Open SQL, Conn, 3, 3
Qui parte il controllo che lo username non sia stato già utilizzato:
IF Not RecSet.Eof Then
usato = True
Else
usato = False
End IF
' Chiude la connessione al DB
RecSet.Close
Set RecSet = Nothing
IF usato = True then ( USERNAME GIA' USATO )
Else ( USERNAME DISPONIBILE USATO )
Set RecSet = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM TABELLA_UTENTI Order By ID Desc"
RecSet.Open SQL, Conn, 3, 3
RecSet.Addnew
RecSet("username") = username
RecSet("password") = password
RecSet("email") = email
.......
Non va...
Ho sbagliato tutto giusto?
</style>
<script language="javascript">
<!--
function Modulo() {
// Variabili associate ai campi del modulo
var nome = document.modulo.nome.value;
var cognome = document.modulo.cognome.value;
var data_di_nascita = document.modulo.data_di_nascita.value;
var codice_fiscale_o_partita_iva = document.modulo.codice_fiscale_o_partita_iva.value ;
var indirizzo = document.modulo.indirizzo.value;
var civico = document.modulo.civico.value;
var cap = document.modulo.cap.value;
var citta = document.modulo.citta.value;
var provincia = document.modulo.provincia.value;
var regione = document.modulo.regione.value;
var nazione = document.modulo.nazione.value;
var cb = document.modulo.cb.checked;
var cellulare = document.modulo.cellulare.value;
var email = document.modulo.email.value;
var login = document.modulo.login.value;
var pass = document.modulo.pass.value;
var conferma = document.modulo.conferma.value;
// Espressione regolare dell'email
var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
//Effettua il controllo sul campo NOME
if ((nome == "") || (nome == "undefined")) {
alert("Il campo Nome è obbligatorio.");
document.modulo.nome.focus();
return false;
}
//Effettua il controllo sul campo COGNOME
else if ((cognome == "") || (cognome == "undefined")) {
alert("Il campo Cognome è obbligatorio.");
document.modulo.cognome.focus();
}
//Effettua il controllo sul campo DATA DI NASCITA
else if (document.modulo.data_di_nascita.value.substring(2 ,3) != "/" ||
document.modulo.data_di_nascita.value.substring(5, 6) != "/" ||
isNaN(document.modulo.data_di_nascita.value.substr ing(0,2)) ||
isNaN(document.modulo.data_di_nascita.value.substr ing(3,5)) ||
isNaN(document.modulo.data_di_nascita.value.substr ing(6,10))) {
alert("Inserire nascita in formato gg/mm/aaaa");
document.modulo.data_di_nascita.value = "";
document.modulo.data_di_nascita.focus();
return false;
return false;
}
else if (document.modulo.data_di_nascita.value.substring(0 ,2) > 31) {
alert("Impossibile utilizzare un valore superiore a 31 per i giorni");
document.modulo.nascita.select();
return false;
}
else if (document.modulo.data_di_nascita.value.substring(3 ,5) > 12) {
alert("Impossibile utilizzare un valore superiore a 12 per i mesi");
document.modulo.data_di_nascita.value = "";
document.modulo.data_di_nascita.focus();
return false;
}
else if (document.modulo.data_di_nascita.value.substring(6 ,10) < 1900) {
alert("Impossibile utilizzare un valore inferiore a 1900 per l'anno");
document.modulo.data_di_nascita.value = "";
document.modulo.data_di_nascita.focus();
return false;
}
//Effettua il controllo sul campo codice_fiscale_o_partita_iva
else if ((codice_fiscale_o_partita_iva == "") || (codice_fiscale_o_partita_iva == "undefined")) {
alert("Il campo Codice fiscale / P. iva è obbligatorio.");
document.modulo.codice_fiscale_o_partita_iva.focus ();
}
//Effettua il controllo sul campo INDIRIZZO
else if ((indirizzo == "") || (indirizzo == "undefined")) {
alert("Il campo Indirizzo è obbligatorio.");
document.modulo.indirizzo.focus();
return false;
}
//Effettua il controllo sul campo civico
else if ((civico == "") || (civico == "undefined")) {
alert("Il campo Civico è obbligatorio.");
document.modulo.civico.focus();
}
//Effettua il controllo sul campo cap
else if ((cap == "") || (cap == "undefined")) {
alert("Il campo C.A.P. è obbligatorio.");
document.modulo.cap.focus();
}
//Effettua il controllo sul campo cap
else if ((cb == "") || (cb == "undefined")) {
alert("Accettare trattamento della privacy.");
document.modulo.cb.focus();
}
//Effettua il controllo sul campo CITTA'
else if ((citta == "") || (citta == "undefined")) {
alert("Il campo Città è obbligatorio.");
document.modulo.citta.focus();
return false;
}
//Effettua il controllo sul campo provincia
else if ((provincia == "") || (provincia == "undefined")) {
alert("Il campo Provincia è obbligatorio.");
document.modulo.provincia.focus();
return false;
}
//Effettua il controllo sul campo regione
else if ((regione == "") || (regione == "undefined")) {
alert("Il campo Regione è obbligatorio.");
document.modulo.regione.focus();
return false;
}
//Effettua il controllo sul campo nazione
else if ((nazione == "") || (nazione == "undefined")) {
alert("Il campo Nazione è obbligatorio.");
document.modulo.nazione.focus();
return false;
}
//Effettua il controllo sul campo cellulare
else if ((isNaN(cellulare)) || (cellulare == "") || (cellulare == "undefined")) {
alert("Il campo Cellulare è numerico ed obbligatorio.");
document.modulo.cellulare.value = "";
document.modulo.cellulare.focus();
return false;
}
else if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
alert("Inserire un indirizzo E-mail corretto.");
document.modulo.email.select();
return false;
}
//Effettua il controllo sul campo login
else if ((login == "") || (login == "undefined")) {
alert("Il campo Login è obbligatorio.");
document.modulo.login.focus();
return false;
}
//Effettua il controllo sul campo PASSWORD
else if ((pass == "") || (pass == "undefined")) {
alert("Il campo Password è obbligatorio.");
document.modulo.pass.focus();
return false;
}
//Effettua il controllo sul campo CONFERMA PASSWORD
else if ((conferma == "") || (conferma == "undefined")) {
alert("Il campo Conferma password è obbligatorio.");
document.modulo.conferma.focus();
return false;
}
//Verifica l'uguaglianza tra i campi PASSWORD e CONFERMA PASSWORD
else if (pass != conferma) {
alert("La password confermata è diversa da quella scelta, controllare.");
document.modulo.conferma.value = "";
document.modulo.conferma.focus();
return false;
}
//INVIA IL MODULO
else {
document.modulo.action = "inserisci.asp";
document.modulo.submit();
}
}
url_DB = mdb-database/utenti.mdb
Set Conn = Server.CreateObject("ADODB.Connection")
conn.Open url_DB
Set RecSet = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM UTENTI where username = '" & username &"'"
RecSet.Open SQL, Conn, 3, 3
IF Not RecSet.Eof Then
usato = True
Else
usato = False
End IF
RecSet.Close
Set RecSet = Nothing
IF usato = True then ( USERNAME GIA' USATO )
Else ( USERNAME DISPONIBILE USATO )
Set RecSet = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM TABELLA_UTENTI Order By ID Desc"
RecSet.Open SQL, Conn, 3, 3
RecSet.Addnew
RecSet("login") = login
RecSet("email") = email
RecSet("codice_fiscale_o_partita_iva") = codice_fiscale_o_partita_iva
RecSet("telefono") = telefono
RecSet("cellulare") = cellulare
RecSet("sito_internet") = sito_internet
//-->
</script>
che errore restituisce?
1. "non va" non vuol dire niente. occorre essere più precisi
2. hai mescolato js e vbs
Ma queste stringhe devo inserirle nella parte dove verranno inseriti i dati o nella pagina che collega il tutto al database?
"queste stringhe" sarebbero dei comandi, righe di codice. Ovviamente vanno inserite nella parte di programma interessato, è dall'inizio che te lo stiamo dicendo: prima di fare la INSERT fai la SELECT; se ti riporta qualcosa, il record c'è già; se invece il recordset è vuoto, puoi procedere con l'inserimento. Buon lavoroOriginariamente inviato da enrico16101990
Ma queste stringhe devo inserirle nella parte dove verranno inseriti i dati o nella pagina che collega il tutto al database?![]()