Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42215

Website Form

$
0
0
I'm not completely sure that this is the right forum to use, so I apologize if I'm in the wrong place. I was playing around with an existing webpage. I saved a copy of it before I made any changes. However, I somehow made changes to both the original and the copy and I can't fix it. I'm very new to javascript but I usually can make small tweaks here and there on an existing page. No luck this time.

Here's what I was trying to accomplish: I had a form where users could enter their contact information and how much they wanted to donate to our organization. The form would send an email to myself and a few others who are approved to receive encrypted messages on the server. I wanted to duplicate this page and simply change the options on the form. I wanted it to be a simple email subscription form - just a name and an email address to submit. I wanted the form to send an email in the same way it did for the donation form. After all, we simply need the email so we are notified of the entry and we can act from there.

When I made changes to the original, I saved to see the results on the website. That's when I realized I wasn't working on the right page. I don't know how to retrieve the original coding so I'm attempting to either restore the old form. If that's not possible, I'd like to re-create it. The form coding is below, after my attempt to restore it. (which is not working)

Right now, it's giving me an error, and it's sending an email to one person on the server (my boss) but it's not including the details the user submits. I'm not receiving the email and my boss is getting an error when she tries to forward to me (could be that I'm not yet setup to receive encrypted messages as we thought).

<!--#include file = "include.asp"-->

<br />

<H4>Donate on Your Utility Bill</H4>

<%
DonateByUtility

sub DonateByUtility()
dim sMode
sMode = trim(request("mode") & "")
if (sMode = "") then
sMode = "entry"
end if

dim sErrMsg
sErrMsg = ""
if (sMode = "validate") then
ValidateEntry sMode, sErrMsg
end if

select case sMode
case "entry"
EntryScreen sErrMsg
end select

end sub

sub EntryScreen( sErrMsg )
dim sName, sEMail, sYourName, sAddress, sCity, sStateProv, sZip, sUtilityCompany, sXcelAcctNo, sAmount, sOtherAmount
sName = trim(request("name") & "")
sEMail = trim(request("email") & "")
sAddress = trim(request("address") & "")
sCity = trim(request("city") & "")
sStateProv = trim(request("state_prov") & "")
sZip = trim(request("zip") & "")
sUtilityCompany = trim(request("utility_company") & "")
sAmount = trim(request("amount") & "")
sOtherAmount = trim(request("other_amount") & "")
%>

<script language="javascript">
//<!--
function confirm_submit() {
var sValue = document.form1.Amt.value;
if (sValue == '')
if (sValue == "0") {
alert('You must enter an a dollar amount before submitting this form.');
}
else {
if (confirm('By selecting "OK" below, you are confirming that you wish to donate' + 'sValue'+ 'through your utility bill'
)) {
document.form1.submit();
}
}
}
//-->
</script>

<table width="95%" cellspacing="0" cellpadding="5" border="0">
<form name="form1" action="<%=sScriptName%>" method="post">
<input type="hidden" name="mode" value="validate">

<% if (sErrMsg <> "") then %>
<tr>
<td colspan="2" align="center">
<font color="red"><b><%=sErrMsg%></b></font><br>
<br>
</td>
</tr>
<% end if %>

<tr>
<td align="right" valign="top" width="35%">Name:</td>
<td width="65%"><input size="30" name="name" value="<%=sName%>"></td>
</tr>
<tr>
<td align="right">Email Address:</td>
<td><input size="30" name="email" value="<%=sEMail%>"></td>
</tr>
<tr>
<td align="right">Address:</td>
<td><input size="30" name="address" value="<%=sAddress%>"></td>
</tr>
<tr>
<td align="right">City:</td>
<td><input size="30" name="city" value="<%=sCity%>"></td>
</tr>
<tr>
<td align="right">State/Province:</td>
<td><input size="10" name="state_prov" value="<%=sStateProv%>"></td>
</tr>
<tr>
<td align="right">Zip/Postal:</td>
<td><input size="10" name="zip" value="<%=sZip%>"></td>
</tr>

<tr>
<td align="right">Utility Company:</td>
<td><input size="10" name="utility" value="<%=sutility%>"></td>
</tr>

<tr>
<td align="right">Utility Account Number:</td>
<td><input size="10" name="UtilAcct" value="<%=sUtilAcct%>"></td>
</tr>

<tr>
<td align="right">Donation Amount:</td>
<td><input size="10" name="Amt" value="<%=sAmt%>"></td>
</tr>

<tr>
<td align="right" valign="top" colspan="2" height="108">
<hr>
<p align="center">Some utilities match customer donations. If your
utility <br>participates, we will contact them to match your
donation.<br>
&nbsp;<hr></td>
</tr>

<tr>
<td colspan="2" align="center">
<input type="button" value="Submit" onclick="confirm_submit();" id=button1 name=button1>
</td>
</tr>
</form>
</table>

<%
end sub

sub WriteOption( sDisplay, sValue, sCurValue )
dim sSelected
sSelected = ""
if (sValue = sCurValue) then
sSelected = " selected"
end if

Response.write "<option value=""" & sValue & """" & sSelected & ">" & sDisplay & "</option>" & vbcrlf
end sub ' WriteOption

sub ValidateEntry( sMode, sErrMsg )
dim sName, sEMail, sYourName, sAddress, sCity, sStateProv, sZip, sUtilityCompany, sXcelAcctNo, sAmount, sOtherAmount
sName = trim(request("name") & "")
sEMail = trim(request("email") & "")
sYourName = trim(request("your_name") & "")
sAddress = trim(request("address") & "")
sCity = trim(request("city") & "")
sStateProv = trim(request("state_prov") & "")
sZip = trim(request("zip") & "")
sUtilityCompany = trim(request("utility_company"))
sXcelAcctNo = trim(request("xcel_acct_no") & "")
sAmount = trim(request("amount") & "")
sOtherAmount = trim(request("other_amount") & "")

if (sName = "") then
sErrMsg = sErrMsg _
& "<li>You must enter your name.</li>" & vbcrlf
end if
if (sEMail = "") then
sErrMsg = sErrMsg _
& "<li>You must enter your e-mail address</li>" & vbcrlf
end if
if (sOtherAmount = "") then
if (sAmount = "0") then
sErrMsg = sErrMsg _
& "<li>You have not selected an amount to donate</li>" & vbcrlf
end if
else
if (not isnumeric(sOtherAmount)) then
sErrMsg = sErrMsg _
& "<li>The amount you entered does not appear to be a numeric amount</li>" & vbcrlf
end if
end if
if ((sAddress = "") or (sCity = "") or (sStateProv = "")) then
sErrMsg = sErrMsg _
& "<li>You must give us your full address</li>" & vbcrlf
end if
if (sErrMsg = "") then
SendEmail
else
sMode = "entry"
end if
end sub ' ValidateEntry


sub SendEmail()
dim sName, sEMail, sYourName, sAddress, sCity, sStateProv, sZip, sUtilityCompany, sXcelAcctNo, sAmount, sOtherAmount
sName = trim(request("name") & "")
sEMail = trim(request("email") & "")
sYourName = trim(request("your_name") & "")
sAddress = trim(request("address") & "")
sCity = trim(request("city") & "")
sStateProv = trim(request("state_prov") & "")
sZip = trim(request("zip") & "")
sUtilityCompany = trim(request("utility_company"))
sXcelAcctNo = trim(request("xcel_acct_no") & "")
sAmount = trim(request("amount") & "")
sOtherAmount = trim(request("other_amount") & "")

dim sSubject, sSendEMail, sBody
sSubject = "Monthly Donation Request"
sSendEMail = GetKeyValueData("APPLICATION", "UtilityBillEMail")
sBody = "A Monthly Donation request was received on " & now() & vbcrlf _
& "Request Details:" & vbcrlf & vbcrlf _
& "Name: " & ucase(sName) & vbcrlf _
& "EMail: " & ucase(sEMail) & vbcrlf _
& "Your Name: " & ucase(sYourName) & vbcrlf _
& "Address: " & ucase(sAddress) & vbcrlf _
& "City: " & ucase(sCity) & vbcrlf _
& "State/Prov: " & ucase(sStateProv) & vbcrlf _
& "Zip: " & ucase(sZip) & vbcrlf _
end sub 'Send Email


if (SERVER_NAME <> "merlin") then
if 1=0 Then

Set oMail = Server.CreateObject("Persits.MailSender")
oMail.Host = "localhost"
oMail.From = "web@energyoutreach.org"
oMail.AddAddress u_form_destination1
oMail.Subject = sSubject
oMail.isHTML = true
oMail.Body = "<HTML><BODY><PRE>" + sBody + "</PRE></BODY></HTML>"
oMail.Send
Set oMail = Nothing

Set oMail = Server.CreateObject("Persits.MailSender")
oMail.Host = "localhost"
oMail.From = "web@energyoutreach.org"
oMail.AddAddress u_form_destination2
oMail.Subject = sSubject
oMail.isHTML = true
oMail.Body = "<HTML><BODY><PRE>" + sBody + "</PRE></BODY></HTML>"
oMail.Send
Set oMail = Nothing
Else
Set CM = Server.CreateObject("Persits.CryptoManager")
Set Context = CM.OpenContext("", True )
Set oMail = Server.CreateObject("Persits.MailSender")
'response.Write u_encrpytionfile1
Set RecipientCert = CM.ImportCertFromFile(u_encrpytionfile1)
Set Msg = Context.CreateMessage
Msg.AddRecipientCert RecipientCert
oMail.Host = "localhost"
'Eliminate the next two lines to get rid of HTML format:
'oMail.BodyFormat = 0
'oMail.MailFormat = 0
'oMail.Value("Reply-To") = sEMail
oMail.From = "web@energyoutreach.org"
oMail.AddAddress u_form_destination1
oMail.Subject = sSubject
oMail.Body = "<HTML><BODY><PRE>" + sBody + "</PRE></BODY></HTML>"
'oMail.Send
oMail.SendEncrypted Msg ' Use CryptoMessage object
Set oMail = Nothing

Set CM = Server.CreateObject("Persits.CryptoManager")
Set Context = CM.OpenContext("", True )
Set oMail = Server.CreateObject("Persits.MailSender")
Set RecipientCert = CM.ImportCertFromFile(u_encrpytionfile2)
Set Msg = Context.CreateMessage
Msg.AddRecipientCert RecipientCert
oMail.Host = "localhost"
'Eliminate the next two lines to get rid of HTML format:
'oMail.BodyFormat = 0
'oMail.MailFormat = 0
'oMail.Value("Reply-To") = sEMail
oMail.From = "web@energyoutreach.org"
oMail.AddAddress u_form_destination2
oMail.Subject = sSubject
oMail.Body = "<HTML><BODY><PRE>" + sBody + "</PRE></BODY></HTML>"
'oMail.Send
oMail.SendEncrypted Msg ' Use CryptoMessage object
Set oMail = Nothing

Set CM = Server.CreateObject("Persits.CryptoManager")
Set Context = CM.OpenContext("", True )
Set oMail = Server.CreateObject("Persits.MailSender")
Set RecipientCert = CM.ImportCertFromFile(u_encrpytionfile3)
Set Msg = Context.CreateMessage
Msg.AddRecipientCert RecipientCert
oMail.Host = "localhost"
'Eliminate the next two lines to get rid of HTML format:
'oMail.BodyFormat = 0
'oMail.MailFormat = 0
'oMail.Value("Reply-To") = sEMail
oMail.From = "web@energyoutreach.org"
oMail.AddAddress u_form_destination3
oMail.Subject = sSubject
oMail.Body = "<HTML><BODY><PRE>" + sBody + "</PRE></BODY></HTML>"
'oMail.Send
oMail.SendEncrypted Msg ' Use CryptoMessage object
Set oMail = Nothing


end if
else
Response.write "On the live system an email would be sent to: <b>" & sSendEMail _
& "</b><br>Email:<br>" & replace(sBody, vbcrlf, "<br>") & "<br><br>" & vbcrlf
end if
%>

Viewing all articles
Browse latest Browse all 42215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>