12 messaggi dal 11 maggio 2004
Ciao a tutti,
ho montato uno script per la gestione di una mailing list, nel pannello di registrazione alla lista sono elencati solo alcuni campi (nome, email e password), avrei necessità di crearne 2 nuovi (cognome, num cellulare), ho provato ad aggiungere il codice ma senza segnalarmi nessun errore mi iscrive tranquillamente l'indirizzo email alla mailing list, ma se controllo l'inserimento dei dati nel db il campo da me creato risulta vuoto.


Allego la pagina con le mie modifiche, Non riesco a trovare l'errore

<% @ Language=VBScript %>
<% Option Explicit %>
<!--#include file="common.asp" -->
<!--#include file="functions/functions_hash1way.asp" -->
<!--#include file="functions/functions_send_mail.asp" -->
<%


'Set the response buffer to true as we maybe redirecting
Response.Buffer = True

'Declare variables
Dim strEmail 'Holds the users e-mail address
Dim strUserName 'Holds the members name
Dim strPassword 'Holds the user password
Dim blnHTMLformat 'Set to true if email is to be in HTML format
Dim strMessage 'Holds the error message if the user is not entered into the database
Dim strUserCode 'Holds a unique code for the new list member
Dim blnEmailOK 'Set to true if the email address is valid
Dim lngMemberID 'Holds the members ID number
Dim laryCatID 'Holds the cat ID
Dim blnChecked 'Set to true if the category checkbox is to be checked
Dim blnEmailExists 'Set to true if the email address is already in the database
Dim strSubject 'Holds the subject of te email
Dim strEmailBody 'Holds the email body
Dim strSaltValue 'Holds the salt value for ecrypted passwords
Dim strNum_Cell 'Aggiunta del campo numero cellulare

'Initialise variables
blnEmailOK = True
blnEmailExists = false
lngMemberID = 0

'Read in the email address
strEmail = Trim(Mid(LCase(Request("email")), 1, 35))

'Clean up the email address address getting rid of unwanted characters
strEmail = characterStrip(strEmail)



'Read in the form details
If Request.Form("postBack") Then

'Check to see if the user has entered an e-mail address and that it is a valid address
If Len(strEmail) < 5 OR NOT Instr(1, strEmail, " ") = 0 OR InStr(1, strEmail, "@", 1) < 2 OR InStrRev(strEmail, ".") < InStr(1, strEmail, "@", 1) Then

'Set an error message if the users has not enetered a valid e-mail address
blnEmailOK = False

'Else the email address is OK
Else
blnEmailOK = True
End If

'Read in the form details
strUserName = removeAllTags(Trim(Mid(Request.Form("name"), 1, 25)))
strPassword = removeAllTags(Trim(Mid(Request.Form("password"), 1, 25)))
If blnPlainTextOption = true Then blnHTMLformat = CBool(Request.Form("HTMLformat")) Else blnHTMLformat = true
End If



'If this is a post back run the add new or update code
If Request.Form("postBack") AND blnEmailOK AND strUserName <> "" AND strPassword <> "" Then

'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT " & strDbTable & "Members.* FROM " & strDbTable & "Members;"

With rsCommon

'Set the cursor type property of the record set to Dynamic so we can navigate through the record set
.CursorType = 2

'Set the Lock Type for the records so that the record set is only locked when it is updated
.LockType = 3

'Query the database
.Open strSQL, adoCon


'Calculate a code for the user
strUserCode = hexValue(20)

'Loop through all the records in the recordset to check that the user id and the e-mail address are not already in the database
Do While NOT .EOF

'If there is no user code or it is already in the database make a new one and serch the recordset from the begining again
If strUserCode = .fields("ID_Code") Then

'Calculate a code for the user
strUserCode = hexValue(20)

'Move to the first record to make sure the new user code is not in the database
.MoveFirst
End If

'If the e-mail address is already in the database then this is an update so exit loop
If strEmail = .fields("Email") Then

'Set the blnEmailExists variable to true
blnEmailExists = true

'Exit the for loop
Exit Do
End If

'Move to the next record in the recordset
.MoveNext
Loop


'If the email doesn't already exsist then enter the email into the database
If blnEmailExists = False Then

'Encrypt password
If blnEncryptPasswords Then

'generate a salt value
strSaltValue = hexValue(Len(strPassword))

'Concatenate salt value to the password
strPassword = strPassword & strSaltValue

'Encrypt the password
strPassword = HashEncode(strPassword)
End If



'Add new record to a new recorset
.AddNew

'Set database fields
.Fields("Email") = strEmail
.Fields("Name") = strUserName
' aggiunta del campo num_cell
.Fields("num_cell") = strNum_Cell

.Fields("Password") = strPassword
If blnEncryptPasswords Then .Fields("Salt") = strSaltValue
.Fields("ID_Code") = strUserCode
.Fields("HTMLformat") = blnHTMLformat
.Fields("Active") = False

'Update the database
.Update


'Requery database to get the new id number
.Requery

'Move to the last record
.MoveLast

'Get the id number
lngMemberID = CLng(.fields("Mail_ID"))
End If

'Reset recordset variable
.Close
End With



'If the email doesn't already exsist then enter the categoriy details into the database
If blnEmailExists = False Then

'Add the category details to the database
For each laryCatID in Request.Form("catID")

'Add cat choices
strSQL = "INSERT INTO " & strDbTable & "MemCat " & _
"(" & _
"[Mail_ID], " & _
"[Cat_ID] " & _
") " & _
"VALUES " & _
"('" & lngMemberID & "', " & _
"'" & CLng(laryCatID) & "' " & _
")"

'Write to database
adoCon.Execute(strSQL)
Next




'If email activation of account is enabled then get send an activation email
If blnActivate Then

'Set the subject of the email
strSubject = strWebsiteName & ": Conferma la Tua Richiesta di iscrizione alla Newsletter"

'set the message body of the activation email
strEmailBody = "Benvenuto " & strUserName & "," & _
vbCrLf & vbCrLf & "Saluti da " & strWebsiteName & "." & _
vbCrLf & vbCrLf & "Abbiamo ricevuto una richiesta di iscrizione ad una o più categorie della mailing list di " & strWebsiteName & " " & _
vbCrLf & vbCrLf & "Per attivare la tua iscrizione è necessario ciccare sul link sottostante:-" & _
vbCrLf & vbCrLf & strWebsiteAddress & "/activate.asp?ID=" & strUserCode & _
vbCrLf & vbCrLf & "Se non ti fossi iscritto o se questa email è stata inviata per errore ti preghiamo di ignorarla. Non è necessario che tu faccia altro." & _
vbCrLf & vbCrLf & "Grazie per il tuo interessamento." & _
vbCrLf & vbCrLf & "Cordiali saluti," & _
vbCrLf & vbCrLf & strWebsiteName


'Create email object
Call createMailObject(strMailComponent)

'***** START WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
'Write a remove from mailing list message to add to the end of the e-mail in HTML Format
strEmailBody = strEmailBody & mailBody("text", strEmail, blnLCode)
'***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******

'Send the email
Call SendMail(strUserName, strEmail, strMailComponent, "text")

'Drop email component
Call dropMailObject(strMailComponent)

'Clean up
Set rsCommon = Nothing
adoCon.Close
Set adoCon = Nothing


'Redirect to actiavtion page
Response.Redirect("activate_confirm.asp")

End If

'Clean up
Set rsCommon = Nothing
adoCon.Close
Set adoCon = Nothing


'Redirect to actiavtion page
Response.Redirect("activate.asp?ID=" & strUserCode)
End If

End If

%>
<html>
<head>
<title>Mailing List: Crea un Account</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<!-- Web Wiz Mailing List by Bruce Corkhill ©2001-2004
editing by elivenCreations -->

<script language="JavaScript">

//Function to check form is filled in correctly before submitting
function CheckForm () {

var errorMsg = "";

//Check for a name
if (document.frmRegister.name.value.length == ''){
errorMsg += "\n\tName \t\t- Enter your name";
}

//If an e-mail is entered check that the e-mail address is valid
if (document.frmRegister.email.value == "" || (document.frmRegister.email.value.indexOf("@",0) == -1||document.frmRegister.email.value.indexOf(".",0) == -1)) {
errorMsg +="\n\tEmail\t\t- Enter your valid email address";

}
// aggiunta del controllo per il numero di cell

//Check for a telephone
if (document.frmRegister.num_cell.value.length == ''){
errorMsg += "\n\tName \t\t- Enter your phone";
}

//Check for a password
if (document.frmRegister.password.value.length <= 3){
errorMsg += "\n\tPassword \t- Your Password must be at least 4 characters";
}

//Check both passwords are the same
if ((document.frmRegister.password.value) != (document.frmRegister.password2.value)){
errorMsg += "\n\tPassword Error\t- The passwords entered do not match";
document.frmRegister.password.value = ""
document.frmRegister.password2.value = ""
}

//If there is aproblem with the form then display an error
if (errorMsg != ""){
msg = "_______________________________________________________________\n\n";
msg += "The form has not been submitted because there are problem(s) with the form.\n";
msg += "Please correct the problem(s) and re-submit the form.\n";
msg += "_______________________________________________________________\n\n";
msg += "The following field(s) need to be corrected: -\n";

errorMsg += alert(msg + errorMsg + "\n\n");
return false;
}

return true;
}

</script>

<!-- #include file="includes/header.asp" -->
<div align="center">
<!-- <span class="heading"><% = strWebsiteName %>'s Mailing List Create Account</span><br /> -->
<span class="heading">Crea un Account</span><br />

<div align="center">
<%

'If there is a problem tell the user
If blnEmailOK = false OR blnEmailExists OR (Request.Form("postBack") AND (strUserName = "" OR strPassword = "")) Then

%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center" class="error"><br />
<strong>La tua iscrizione non può essere processata.</strong><br /><%

If blnEmailOK = false Then
Response.Write("L'indirizzo email inserito non è valido! Siete pregati di inserire un indirizzo email valido.")
ElseIf blnEmailExists Then
Response.Write("L'indirizzo email inserito, " & strEmail & " è già presente nella newsletter. Inserite <a href=""default.asp?email=" & Server.URLEncode(strEmail) & """>QUI</a> il vostro indirizzo per controllare e modificare il vostro Account.")
ElseIf strUserName = "" Then
Response.Write("Siete pregati di inserire un un nome valido.")
ElseIf strPassword = "" Then
Response.Write("Siete pregati di inserire una password valida.")
End If
%>
</tr>
</table>
<%

End If

%>
<br />
<form name="frmRegister" method="post" action="sign_up.asp" onSubmit="return CheckForm();">
<table width="95%" border="0" cellspacing="0" cellpadding="1" bgcolor="<% = strTableBorderColour %>" align="center">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="<% = strTableBgColour %>">
<tr>
<td bgcolor="<% = strTableTitleColour %>">
<table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="<% = strTableBgColour %>">
<tr bgcolor="<% = strTableTitleColour %>">
<td colspan="2" background="<% = strTableTitleBgImage %>" class="tHeading">Dettagli Nuovo Account<span class="smText"> (tutti
i campi sono obbligatori) </span></td>
</tr>
<tr bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>">
<td colspan="2" background="<% = strTableBgImage %>" bgcolor="<% = strTableColour %>" class="text">
<!-- Please register to activate your mailing list subscription. You will periodically be notified of important <% = strWebsiteName %> features and news. Naturally, you can unsubscribe from the mailing list at any time. -->
</td>
</tr>
<tr bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>">
<td width="289" background="<% = strTableBgImage %>" bgcolor="<% = strTableColour %>" class="text">Nome:</td>
<td width="677" background="<% = strTableBgImage %>" bgcolor="<% = strTableColour %>" class="text"><input name="name" type="text" id="name" size="25" maxlength="25" value="<% = strUserName %>" /></td>
</tr>
<tr bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>">
<td background="<% = strTableBgImage %>" bgcolor="<% = strTableColour %>" class="text">
Indirizzo Email:</td>
<td bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>" class="text"><input name="email" type="text" id="email" size="25" maxlength="50" value="<% = strEmail %>" /></td>
</tr>
<!-- Aggiunta del campo Numero Cellulare ----- PROBLEMI ---Non Scrive nel DB -------------------- -->
<tr bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>">
<td background="<% = strTableBgImage %>" bgcolor="<% = strTableColour %>" class="text">
Numero Cellulare:</td>
<td bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>" class="text"><input name="num_cell" type="text" id="num_cell" size="25" maxlength="50" value="<% = strNum_Cell %>" /></td>
</tr>

<tr bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>">
<td background="<% = strTableBgImage %>" bgcolor="<% = strTableColour %>" class="text">Password: </td>
<td bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>" class="text"><input name="password" type="password" id="password" size="25" maxlength="25" /></td>
</tr>
<tr bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>">
<td background="<% = strTableBgImage %>" bgcolor="<% = strTableColour %>" class="text">Conferma Password: </td>
<td bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>" class="text"><input name="password2" type="password" id="password2" size="25" maxlength="25" /></td>
</tr><%

'If the user can choose to have a plain text email sent give them the option
If blnPlainTextOption Then

%>
<tr bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>">
<td background="<% = strTableBgImage %>" bgcolor="<% = strTableColour %>" class="text">
Formato Newsletter:
<input type="hidden" name="postBack" value="true" /></td>
<td bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>" class="text"><input name="HTMLformat" type="radio" value="true" checked />HTML <input name="HTMLformat" type="radio" value="false" />Testo</td>
</tr><%
End If

%>
<tr align="center" bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>">
<td colspan="2" background="<% = strTableBgImage %>" bgcolor="<% = strTableBottomRowColour %>" class="text"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<br>
<table width="95%" border="0" cellspacing="0" cellpadding="1" bgcolor="<% = strTableBorderColour %>" align="center">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="<% = strTableBgColour %>">
<tr>
<td bgcolor="<% = strTableTitleColour %>">
<table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="<% = strTableBgColour %>">
<tr bgcolor="<% = strTableTitleColour %>">
<td colspan="2" background="<% = strTableTitleBgImage %>" class="tHeading">
Categorie Mailing List </td>
</tr>
<tr bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>">
<td colspan="2" background="<% = strTableBgImage %>" bgcolor="<% = strTableColour %>" class="text">Per favore seleziona dalla lista sottostante a quali categorie di mailing list sei interessato.
Selezionale quante vuoi. Puoi modificare il tuo profilo in qualsiasi momento per cambiare le tue iscrizioni.
<!-- Please select from the list below which <% = strWebsiteName %> mailing list categories that you are interested in. Select as many categories as you wish. You can modify your profile at any time to change your subscriptions.-->
</td>
</tr><%

'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT " & strDbTable & "Category.* FROM " & strDbTable & "Category ORDER BY Cat_Order ASC;"

'Query the database
rsCommon.Open strSQL, adoCon


'Loop through cats
Do While NOT rsCommon.EOF

'Initliase variable
blnChecked = false


'Check to see if the user has checked this in last submission
If Request.Form("postBack") Then
For each laryCatID in Request.Form("catID")

'If the cat has been checked before set blnChecked to true
If CLng(laryCatID) = CLng(rsCommon("Cat_ID")) Then blnChecked = true
Next
End If

Response.Write(vbCrLf & " <tr> " & _
vbCrLf & " <td width=""1%"" background=""" & strTableBgImage & """ bgcolor=""" & strTableColour & """ align=""right""><input type=""checkbox"" name=""catID"" id=""catID"" value=""" & rsCommon("Cat_ID") & """")
If blnChecked = true then Response.Write(" checked")
Response.Write(" /></td>" & _
vbCrLf & " <td width=""99%"" background=""" & strTableBgImage & """ bgcolor=""" & strTableColour & """ class=""text"">" & rsCommon("Cat_Name") & "</td>" & _
vbCrLf & " </tr>")

'Move to next record in rs
rsCommon.MoveNext
Loop

'Clean up
Set rsCommon = Nothing
adoCon.Close
Set adoCon = Nothing
%>
<tr align="center" bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>">
<td colspan="2" background="<% = strTableBgImage %>" bgcolor="<% = strTableBottomRowColour %>" class="text"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<br>
<span class="text">
<input type="submit" name="Submit" value="Crea il Mio Account"></span>
<br /><br /><a href="privacy.asp" class="smLink">Regole sulla Privacy</a>
</form>
<%


Response.Write("<br />")

'Copyright
If blnLCode Then
Response.Write("<span class=""smText"">Powered by Web Wiz Mailing List </span>")
Response.Write("<br /><span class=""smText"">Copyright ©2001-2004 Web Wiz Guide</span>")
End If
%>

</div>
</div>
<!--#include file="includes/footer.asp" -->


Grazie per l'aiuto :)
elisa
2.907 messaggi dal 15 maggio 2001
Contributi
X forza che è vuoto... non dai nessun valore alla variabile strNum_Cell che dovrebbe essere inserita nel record..


Dim strNum_cell
Dim strCognome


poi valorizzi le variabili con quello che ti arriva via form e fai un po' di pulizia attraverso la funzione "removeAllTags"
("ovviamente io scrivo numcellulare e cognome ipotizzando che il nome del mio elemento nel form sia chiamato così")

strNum_cell = removeAllTags(Trim(Mid(Request.Form("numcellulare"), 1, 25))) 
strCognome = removeAllTags(Trim(Mid(Request.Form("cognome"), 1, 25))) 


poi aggiungi i campi
.Fields("num_cell") = strNum_Cell 
.Fields("cognome") = strCognome

Modificato da rome il 31 agosto 2004 23.13 -
12 messaggi dal 11 maggio 2004
Innanzitutto grazie! :)

Ho seguito le tue indicazioni e adesso scrive nel db, ma nn ho capito la funzione "removeAllTags", a cosa serve?

grazie per l'aiuto
elisa
2.907 messaggi dal 15 maggio 2001
Contributi
Prego figurati !

Non vedendo com'è strutturata, posso solo ipotizzare ("dal nome") che la funzione removeAllTags esegua una "pulitura" dei caratteri "maliziosi" di ciò che gli viene passato...

I caratteri cosiddetti maliziosi in una query sql sono per esempio l'apice singolo ' oppure # etc..
Essi posso dare l'opportunità ad un possibile malintenzionato di sottomettere delle query errate e quindi di intrufolarsi nel sistema...

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.