My webpage sends email out then submit is clicked, I need it to only send out a email if one of the check boxes on the form has been checked when submited
How can I do this.
my code is below
________________
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859
-1" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Ole
Db" %>
<%@ Import Namespace="System.Web.Mail
" %>
<script language="VB" runat="server">
Sub Submit_Click(Sender as Object, e as EventArgs)
Dim cnn = New OleDbConnection("Provider=
Microsoft.
Jet.OLEDB.
4.0; data source=" & server.mappath("cl.mdb"))
Dim cmd As New OleDb.OleDbCommand
Page.Validate
If Page.IsValid Then
cmd.CommandText = "INSERT INTO members (title, first_name, last_name, company_name, house_number_name, street, address1, address2, town, postcode, telephone, fax, email, pass, web_address, sector, no_employees, hear_about_us, callback, keep_todate) VALUES ('" & title.Value & "', '" & first_name.Value & "', '" & last_name.Value & "', '" & company_name.Value & "', '" & house_number_name.Value & "', '" & street.Value & "', '" & address1.Value & "', '" & address2.Value & "', '" & town.Value & "', '" & postcode.Value & "', '" & telephone.Value & "', '" & fax.Value & "', '" & email.Value & "', '" & pass.Value & "', '" & web_address.Value & "', '" & sector.Value & "', '" & no_employees.Value & "', '" & hear_about_us.Value & "', '" & callback.checked & "', '" & keep_todate.checked & "')"
cmd.Connection = cnn
cnn.Open()
cmd.ExecuteNonQuery()
cnn.Close()
cmd.Dispose()
cnn.Dispose()
If request.form("email") <> ""
Dim mail As New MailMessage
mail.From = request.form ("email")
mail.To = "glynj@pcdi.co.uk"
mail.Subject = "Request for call back"
mail.Body = "User submitted a request for call back using the online registration form." & "<br>" & "Client Name: " & request.Form("first_name")
& " " & request.Form("last_name") & "<br>" & "Telephone number recorded: " & request.form ("telephone") & "<br> Email powered by webwordz"
mail.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "10.0.0.2"
SmtpMail.Send(mail)
Dim mail2 As New MailMessage
mail2.From = "somewhere"
mail2.To = request.Form("email")
mail2.Subject = "Thank you for registering"
mail2.Body = "User submitted a request for call back using the online registration form."
mail2.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "10.0.0.2"
SmtpMail.Send(mail2)
End If
Response.Redirect("thankyo
u.html")
Else
'Do Whatever
End IF
end sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/mainT
emplate.dw
t" codeOutsideHTMLIsLocked="f
alse" -->
<head>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="quotes.js"></SCRIPT>
<script>
function quotePrint()
{
var index = parseInt(Math.random()*Quo
tes.length
)
return(Quotes[index])
}
</script>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Register Page</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
<!--
.style6 {font-size: 9px}
-->
</style>
<!-- InstanceEndEditable -->
<link href="stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
font-size: 16px;
font-weight: bold;
}
.style4 {font-size: 14px}
.style5 {font-size: 14px; font-weight: bold; }
-->
</style>
</head>
<body>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td style="width: 5%; background: #EEE; border-right: 1px solid #AAA;"> </td>
<td>
<div class="londonLandscape">
<a href="index.html" target="_self"><img src="images/logo.gif" alt="Connecting London Logo" border="0" align="left" style="margin-right: 10px; "></a>
<img src="images/londonpic.jpg"
alt="Connecting London Logo" align="right">
<div style="padding-top: 15px; "><br />
<span class="textSize style1"><span class="textSize style4">Information - Communications - Technology</span></span><s
pan class="style5"></span><spa
n class="style1"><br />
</span> <span class="blueText">We support you...</span></div>
<span class="blueText">not just your systems!</span></div>
</div>
<div id="topmenu1">
<div style="float:right; "><a href="aboutus.html" target="_self">about us</a> | <a href="contactus.html" target="_self">contact us</a> | <a href="legal.html"> legal</a> | <a href="careers.html" target="_self">careers</a>
| <a href="sitemap.html" target="_self">sitemap</a>
</div>
<!-- InstanceBeginEditable name="stat" -->home>register<!-- InstanceEndEditable -->
</div>
<div style="clear: both; margin-top: 20px;">
<div class="box3">
<div class="specialOfferBox">
<div class="smallTitle" style="color:#FF0000; font-size: 12px;">Special Offer This Month</div>
</div>
<div class="graybox">
<center><b>
<p>EMAIL PROTECTION AGENCY (EPA) SPAM PROTECTION FOR BUSINESS:</p>
<p class="FreeTrial"> FREE 15-DAY TRIAL</p>
<p>EPA Spam Potection is <br>
available to registered <br>
Connecting London <br>
members FREE for 15 days.</p>
</b>
<p>members click here <a href="membercheck.aspx">cl
ick here</a>.
<p class="textSize">If you are not a Connecting London member, and would like to apply for membership please register <span class="redlink"><a href="register.aspx">click
here
</a></span><br>
<br>There's no charge for joining, and you do not have to be an existing client.</p>
</center>
</div>
<div class="smallTitle">Our business partners</div>
<div class="graybox" align="center">
<img src="images/logos.jpg" alt="logos">
</div>
</div>
<div class="box1">
<div id="nav" style="padding-bottom: 30px; ">
<ul class="level1">
<li><a href="index.html"><strong>
Home</stro
ng></a></l
i>
<li><a href="private_clients .html"><strong>Private Client Computing</strong></a></li
>
<li class="submenu"><a href="corporate_client_com
puting.htm
l"><strong
>Corporate
Client Computing </strong></a>
<ul class="level2">
<li><a href="corporate_client_con
sultancy.h
tml">Consu
ltancy</a>
</li>
<li><a href="/">Networks</a></li>
<li><a href="/">Computer Services</a></li>
<li><a href="communications_servi
ces.html">
Communicat
ions Services </a></li>
<li><a href="internet_services.ht
ml">Intern
et Services</a></li>
<li><a href="training_and_familia
risation.h
tml">Train
ing</a></l
i>
<li><a href="service_and_maintena
nce.html">
Service and Maintenance</a></li>
<li><a href="/">Financing</a></li
>
</ul>
</li>
<li><a href="computer_systems_mai
ntenance_s
ervice_and
_support.h
tml"><stro
ng>Service
& Maintenance</strong></a></
li>
<li><a href="case_histories.html"
><strong>C
ase Histories</strong></a></li
>
<li><a href="customer_charter.htm
l"><strong
>Customer Charter</strong></a></li>
</ul>
</div>
<div class="smallTitle" align="right">Members Email Login</div>
<div class="graybox"><form method="post" action="membercheck.aspx">
<center>
User Name
<input name="username" type="text">
Password
<input name="password" type="password">
<br>
<div align="right">
<input name="Login" type="submit" value="Login">
</div>
</center></form>
If you are a registered member and want to access the members area please <a href="membercheck.aspx">cl
ick here</a> </div>
<div class="smallTitle" align="right">What our clients say about us</div>
<div class="graybox">
<script>document.write(quo
tePrint())
</script>
</div>
</div>
<div class="box2">
<!-- InstanceBeginEditable name="content" -->
<div class="graybar"><img src="images/headings/regis
ter.gif" alt="corporate client image"></div>
<p>Welcome to connecting London's registration page. Please fill in the entire form below to register with us. All fields in <b>bold</b> are mandatory.</p>
<form runat="server">
<table width="auto" border="0" align="left" cellpadding="5" cellspacing="0">
<tr>
<td bgcolor="#F7F7F7"><div align="right"><b>Title:</b
></div></t
d>
<td bgcolor="#F7F7F7"><div align="left">
<input name="text" type="text" id="title" value="" runat="server">
</div></td>
<td><div align="left">
<asp:RequiredFieldValidato
r runat=server
ControlToValidate=title
ErrorMessage=""> * </asp:RequiredFieldValidat
or>
</div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right"><b>First Name:</b></div></td>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="first_name" value="" runat="server">
</div></td>
<td><div align="left">
<asp:RequiredFieldValidato
r runat=server
ControlToValidate=first_na
me
ErrorMessage=""> * </asp:RequiredFieldValidat
or>
</div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right"><b>Last Name:</b></div></td>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="last_name" value="" runat="server">
</div></td>
<td><div align="left">
<asp:RequiredFieldValidato
r runat=server
ControlToValidate=last_nam
e
ErrorMessage=""> * </asp:RequiredFieldValidat
or>
</div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right">Company Name:</div></td>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="company_name" value="" runat="server">
</div></td>
<td>
<div align="left"></div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right"><b>Address Number/Name:</b></div></td
>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="house_number_name" value="" runat="server">
</div></td>
<td><div align="left">
<asp:RequiredFieldValidato
r runat=server
ControlToValidate=house_nu
mber_name
ErrorMessage=""> * </asp:RequiredFieldValidat
or>
</div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right"><b>Street</b
></div></t
d>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="street" value="" runat="server">
</div></td>
<td><div align="left">
<asp:RequiredFieldValidato
r runat=server
ControlToValidate=street
ErrorMessage=""> * </asp:RequiredFieldValidat
or>
</div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right"><b>Address 1:</b></div></td>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="address1" value="" runat="server">
</div></td>
<td><div align="left">
<asp:RequiredFieldValidato
r runat=server
ControlToValidate=address1
ErrorMessage=""> * </asp:RequiredFieldValidat
or>
</div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right">Address 2:</div></td>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="address2" value="" runat="server">
</div></td>
<td>
<div align="left"></div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right"><b>Town:</b>
</div></td
>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="town" value="" runat="server">
</div></td>
<td><div align="left">
<asp:RequiredFieldValidato
r runat=server
ControlToValidate=town
ErrorMessage=""> * </asp:RequiredFieldValidat
or>
</div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right"><b>PostCode:
</b></div>
</td>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="postcode" value="" runat="server">
</div></td>
<td><div align="left">
<asp:RequiredFieldValidato
r runat=server
ControlToValidate=postcode
ErrorMessage=""> * </asp:RequiredFieldValidat
or>
</div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right"><b>Telephone
:</b></div
></td>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="telephone" value="" runat="server">
</div></td>
<td><div align="left">
<asp:RequiredFieldValidato
r runat=server
ControlToValidate=telephon
e
ErrorMessage=""> * </asp:RequiredFieldValidat
or>
<asp:RegularExpressionVali
dator runat=server display=dynamic
ControlToValidate="telepho
ne"
ErrorMessage="Tel must be 8 12 nonblank characters."
ValidationExpression="[^\s
]{4,12}"/>
</div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right">Fax Number:</div></td>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="fax" value="" runat="server">
</div></td>
<td>
<div align="left"></div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right"><b>Email Address</b></div></td>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="email" value="" runat="server">
</div></td>
<td>
<div align="left"><asp:RegularE
xpressionV
alidator id="valRegEx" runat="server"
ControlToValidate="email"
ValidationExpression=".*@.
*\..*"
ErrorMessage="Your entry is not a valid e-mail address."
display="dynamic">*
</asp:RegularExpressionVal
idator></d
iv></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right"><b>Password:
</b></div>
</td>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="password" ID="pass" value="" runat="server">
</div></td>
<td><div align="left">
<asp:RequiredFieldValidato
r runat=server
ControlToValidate=pass
ErrorMessage=""> * </asp:RequiredFieldValidat
or>
</div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right">Re-type Password</div></td>
<td bgcolor="#F7F7F7"><div align="left">
<input type="password" ID="passcheck" value="" runat="server">
</div></td>
<td><div align="left">
<asp:CompareValidator runat=server
controltovalidate=pass
controltocompare=passcheck
errormessage="Passwords do not match." />
</div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right">Web Address:</div></td>
<td bgcolor="#F7F7F7">
<div align="left">
<input type="text" ID="web_address" value="" runat="server">
</div></td>
<td>
<div align="left"></div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right">Business Sector:</div></td>
<td bgcolor="#F7F7F7">
<div align="left">
<select id="sector" runat="server">
<option value="None Selected">Select</option>
<option value="Automotive">Automot
ive</optio
n>
<option value="Computers">Computer
s</option>
<option value="Construction">Const
ruction</o
ption>
<option value="Consumer Goods">Consumer Goods</option>
<option value="Education">Educatio
n</option>
<option value="Electronics">Electr
onics</opt
ion>
<option value="Entertainment">Ente
rtainment<
/option>
<option value="Financial Institution">Financial Institution</option>
<option value="Insurance">/Insuran
ce</option
>
<option value="Other">/Other</opti
on>
<option value="Government">Governm
ent</optio
n>
<option value="Military">Military<
/option>
<option value="Public Sector">Public Sector</option>
<option value="Hospitality">Hospit
ality</opt
ion>
<option value="Recreation">Recreat
ion</optio
n>
<option value="Leisure Industry">Leisure Industry</option>
<option value="Manugacturer">Manug
acturer</o
ption>
<option value="Media">Media</optio
n>
<option value="Medical">Medical</o
ption>
<option value="Health Services">Health Services</option>
<option value="Pharmaceuticals">Ph
armaceutic
als</optio
n>
<option value="Professional Services">Professional Services</option>
<option value="Publishers">Publish
ers</optio
n>
<option value="Retail">Retail</opt
ion>
<option value="Telecommunications"
>Telecommu
nications<
/option>
<option value="Travel">Travel</opt
ion>
<option value="Transportation">Com
puters</op
tion>
</select>
</div></td>
<td>
<div align="left"></div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right">No. Employees:</div></td>
<td bgcolor="#F7F7F7">
<div align="left">
<select id="no_employees" runat="server">
<option value="None Selected">Select</option>
<option>1-10</option>
<option>11-25</option>
<option>26-50</option>
<option>50+</option>
</select>
</div></td>
<td>
<div align="left"></div></td>
</tr>
<tr>
<td bgcolor="#F7F7F7"><div align="right">How did you hear about us?</div></td>
<td bgcolor="#F7F7F7">
<div align="left">
<select id="hear_about_us" runat="server">
<option value="None Selected">Select</option>
<option>Colour Pages</option>
<option>Direct Mail</option>
<option>Internet</option>
<option>Referral</option>
<option>Yellow Pages</option>
<option>Yell.com</option>
<option>Other</option>
</select>
</div></td>
<td>
<div align="left"></div></td>
</tr>
<tr>
<td colspan="2" bgcolor="#F7F7F7">Please call me to set-up the EPA (Email Protection Agency) FREE 15 day trial.
<asp:CheckBox ID="callback" runat="server" Checked="true" />
</td>
<td></td>
</tr>
<tr>
<td colspan="2" bgcolor="#F7F7F7">
<td></td>
</tr>
<tr>
<td colspan="2" bgcolor="#F7F7F7">Tick here to keep you up to date with the latest IT devleopments. Get more out of your existing technologies, find out about essential resources, new technology guides & time saving hints to help you get more done, cost effectively. Please untick the box if you do not want to subscribe.
<asp:CheckBox ID="keep_todate" runat="server" Checked="true" /></td>
<td></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="3"><div align="center">
<input type="submit" OnServerClick="Submit_Clic
k" value="Submit" runat="server">
<span class="style6">only submit once
</span> </div></td>
</tr>
</table>
</form>
<!-- InstanceEndEditable --></div>
</div>
<div class="box4">
For more information call:<br>
<b>Gary Howells on 020 7591 5455 or Robert Saleh on 020 7591 5454<br></b>
or <a href="mailto:email sales@connectinglondon.com
">email sales@connectinglondon.com
</a></div>
</td>
<td style="width: 5%; background: #EEE; border-left: 1px solid #AAA;"> </td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>