2 messaggi dal 28 maggio 2003
Ciao sono nei pasticci ho creato con js e asp un inserimento dati in un access ma non riesco a inviare una mail di conferma..
come posso fare..

Grazie Diego

<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file="Connections/Conn.asp" -->
<%
// *** Edit Operations: declare variables

// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
MM_editAction += "?" + Request.QueryString;
}

// boolean to abort record edit
var MM_abortEdit = false;

// query string to execute
var MM_editQuery = "";
%>
<%
// *** Insert Record: set variables

if (String(Request("MM_insert")) == "form1") {

var MM_editConnection = MM_Conn_STRING;
var MM_editTable = "Customers";
var MM_editRedirectUrl = "andes_login.asp";
var MM_fieldsStr = "LastName|value|FirstName|value|CustomerEmail|value|ShipCity|value|ShipAddress|value|ShipRegion|value|Telefono|value|ShipPostalCode|value|Username|value|Password|value";
var MM_columnsStr = "LastName|',none,''|FirstName|',none,''|CustomerEmail|',none,''|ShipCity|',none,''|ShipAddress|',none,''|ShipRegion|',none,''|Telefono|',none,''|ShipPostalCode|',none,''|Username|',none,''|Password|',none,''";

// create the MM_fields and MM_columns arrays
var MM_fields = MM_fieldsStr.split("|");
var MM_columns = MM_columnsStr.split("|");

// set the form values
for (var i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = String(Request.Form(MM_fields[i]));
}

// append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
}
}
%>
<%
// *** Insert Record: construct a sql insert statement and execute it

if (String(Request("MM_insert")) != "undefined") {

// create the sql insert statement
var MM_tableValues = "", MM_dbValues = "";
for (var i=0; i+1 < MM_fields.length; i+=2) {
var formVal = MM_fields[i+1];
var MM_typesArray = MM_columns[i+1].split(",");
var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
if (formVal == "" || formVal == "undefined") {
formVal = emptyVal;
} else {
if (altVal != "") {
formVal = altVal;
} else if (delim == "'") { // escape quotes
formVal = "'" + formVal.replace(/'/g,"''") + "'";
} else {
formVal = delim + formVal + delim;
}
}
MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i];
MM_dbValues += ((i != 0) ? "," : "") + formVal;
}
MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")";

if (!MM_abortEdit) {
// execute the insert
var MM_editCmd = Server.CreateObject('ADODB.Command');
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();

if (MM_editRedirectUrl) {
Response.Redirect(MM_editRedirectUrl);
}
}

}
%>
<%
var strEmailBody
var StrLastName
var StrFirstName
var StrCustomerEmail
var StrShipAddress
var StrShipCity
var StrShipPostalCode
var StrShipRegion
var StrTelefono
var StrUsername
var StrPassword
var strWebmasterEmail
var strSubject


StrLastName= Request.Form("LastName")
StrFirstName= Request.Form("FirstName")
StrCustomerEmail= Request.Form("CustomerEmail")
StrShipAddress= Request.Form("ShipAddress")
StrShipCity= Request.Form("ShipCity")
StrShipPostalCode= Request.Form("ShipPostalCode")
StrShipRegion= Request.Form("ShipRegion")
StrTelefono= Request.Form("Telefono")
StrUsername= Request.Form("Username")
StrPassword= Request.Form("Password")
strWebmasterEmail=Request.Form("diegore@hotmail.com")
strSubject=Request.Form("Dati per registrazione Caal.it")

strEmailBody = strEmailBody & "<br>Hello: " & StrFirstName
strEmailBody = strEmailBody & "<br>Sei Ragistratonel DataBase di www.caal.it"
strEmailBody = strEmailBody & "<br><br>Eccoti i dati di accesso"
strEmailBody = strEmailBody & "<br><br><b>User </b>" & StrUsername
strEmailBody = strEmailBody & "<br><b>Password </b>" & StrPassword
strEmailBody = strEmailBody & " Ti Aspettiamo Distinti Saluti Call.it"

var objCDO

var objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "<" & strAttbi & ">"


objCDO.To = "<" & StrCustomerEmail & ">"
objCDO.cc = "<" & strWebmasterEmail & ">"

objCDO.Subject = strSubject


objCDO.Body = strEmailBody


objCDO.BodyFormat = 0


objCDO.MailFormat = 0


objCDO.Send()

objCDO = Nothing
%>
<html>
<head>
<title>Caal Centro Liturgico</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/Caal.css" rel="stylesheet" type="text/css">
</head>
<body background="Immagini/sfondo.jpg" leftmargin="0" topmargin="0">
<table width="760" border="0" align="center" cellpadding="2" cellspacing="2" class="Bground" >
<tr>
<td width="50%"><table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="center"><a href="PrimoLivello.htm" target="_blank"><img src="Immagini/SalaSfonfo.gif" alt="prova" name="prova" width="300" height="237" border="0"></a></td>
</tr>
<tr>
<td class="Avvertenze" align="center">Clicca sull'Immagine per avere un'anteprima </td>
</tr>
<tr>
<td align="Center"><img name="prova" src="Immagini/logo1.gif" width="150" height="153" alt="prova"></td>

</tr>
</table></td>
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td class="Avvertenze">Per accedere alle sezioni catalogo e scegliere gli articoli che più ti interessano <strong>Registrati</strong></td>
</tr>
</table>



<form method="post" action="<%=MM_editAction%>" name="form1">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">LastName:</td>
<td>
<input type="text" name="LastName" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">FirstName:</td>
<td>
<input type="text" name="FirstName" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">CustomerEmail:</td>
<td>
<input type="text" name="CustomerEmail" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">ShipCity:</td>
<td>
<input type="text" name="ShipCity" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">ShipAddress:</td>
<td>
<input type="text" name="ShipAddress" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">ShipRegion:</td>
<td>
<input type="text" name="ShipRegion" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Telefono:</td>
<td>
<input type="text" name="Telefono" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">ShipPostalCode:</td>
<td>
<input type="text" name="ShipPostalCode" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Username:</td>
<td>
<input type="text" name="Username" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Password:</td>
<td>
<input type="text" name="Password" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td>
<input type="submit" value="Insert Record">
</td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p></td>
</tr>
<tr>
<td class="PowreBy" colspan="2" align="center">Power By Multinet S.r.l. Sito Ottimizzato per una visione 800X600 1024X768 </td>
</tr>
</table>
</body>
</html>

Diego Lucarini
Guarda quante righe di codice per un banale INSERT.
Questo è DW. E poi non capisci dov'è il problema.

Adesso non sto ad analizzare su tutto, comunque vedo che, al termine dello script per l'INSERT, c'è un Response.Redirect.

Non è che è quello? e quindi fa il redirect PRIMA del tuo codice con CDONTS?

----------------------
r.zilipo[SONOSTUFO]@cleverinteractive.it

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.