ehmmmmm..........è tutto!!
quella è la pagina che invia la mail, ho aggiunto la parte di codice che ho trovato sullo script....
nella pagina del form, a parte le if per i controlli sui campi e i tag dell'impaginazione c'è questo nel form:
<FORM method="post" action="inviamailguest.asp?id=1" name="Form1" onSubmit="return control();">
control è la funzione che controlla la validità dei campi....
questo è per intero lo script che ho preso:
<%
if request("id")=1 then
on error resume next
dim strQuery
strQuery="INSERT INTO tabella("
dim strValori
strValori=" VALUES("
dim strSql
strSql=""
for each item in request.form
if item<>"Submit" then
strQuery= strQuery & item &","
strValori= strValori & "'"&server.HTMLEncode(request.form(item))& "',"
end if
next
strQuery=mid(strQuery,1,len(strQuery)-1) &")"
strValori=mid(strValori,1,len(strValori)-1) &")"
set rs =server.createObject("ADODB.Recordset")
strConn="driver={Microsoft Access Driver (.mdb)}; "
strConn=strConn & " DBQ=" & Server.MapPath("database.mdb")
strSql= strQuery & strValori
rs.open strSql,strConn
set rs=nothing
if err.number<>0 then
response.write err.number &"
"&err.description
else
response.write "inserimento avvenuto con successo"
end if
response.end
end if
%>
<form method="post" action="script.asp?id=1">
<input type="text" name="campo1">
<input type="text" name="campo2">
<input type="text" name="campo3">
<input type="submit" name="Submit" value="Invia">
</form>
questa è la funzione control:
function control()
{
var campo1 = document.Form1.campo1.value;
var campo2 = document.Form1.campo2.value;
var campo3 = document.Form1.campo3.value;
var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
var campo4 = document.Form1.campo4.value;
if (campo1 == "")
{
alert("inserire il nome dell'autore");
document.Form1.campo1.focus();
return false;
}
if (campo3 == "")
{
alert("inserire un titolo per il messaggio");
document.Form1.campo3.focus();
return false;
}
if (!email_reg_exp.test(campo2) || (campo2 == "") || (campo2 == "undefined"))
{
alert("Inserire un indirizzo email corretto");
document.Form1.campo2.focus();
return false;
}
if (campo4 == "")
{
alert("inserire un messaggio da inviare ad Agic Consulting");
document.Form1.campo4.focus();
return false;
}
}
</script>



Rispondi quotando
