PDA

View Full Version : New ro ASP, contact form with validation



lemusa
01 Feb 2011, 04:13 AM
Hi new to forum. I have been asked to modify this script on a current contact form to add simple validation and format the resulting email sent to admin. I've never had anything to do with ASP until now and it's doing my head in. Could someone please have a look at the code and give me a few pointers? I've tried everything I can find on the net but I'm doing something wrong because all I manage to achieve is 500 internal errors!

The contact form uses two files, form.asp and _form.asp. The first I believe is purely to contain the _form script.

form.asp


<!--#include file="AuctionSettings.asp"-->
<!--#include virtual="/aucCore/aucEmail.asp"-->
<!--#include virtual="/aucCore/_form.asp"-->
<!--#include virtual="/aucCore/_common.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%
session("curTab") = 3
%>
<html>
<head>
<title><%= Application("auctionname") %> : Affiliate Your School</title>
<link href="style.css" rel="stylesheet" type="text/css">
<!--#include file="metas.asp"-->
</head>
<body topmargin="0" <% if Server.HtmlEncode(request("submit")) = "" then response.write "onLoad=""document.theform.elements[0].focus()""" %>>
<div class="MainContainer">
<!-- #include file="navline.asp" -->
<div>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td valign="top" style="width:180px; margin: 0; padding: 0 5px 0 0;"><!-- #include file="categoryList.asp" --></td>
<td align="center" valign="top" width="100%">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td class="nav_head yellow_top" style="width:100%">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="nav_head_left yellow_left"></td>
<td class="nav_head yellow_mid"><strong>Affiliate Your School</strong></td>
<td class="nav_head_right yellow_right"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="3" class="content_box yellow_box" align="center" width="100%">
<table cellSpacing="0" cellPadding="0" border="0" width="100%">
<tr>
<td align="left">
<% showPage %>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="height: 10px;"><img alt="" src="images/nav/blank.gif" width="2"></td>
</tr>
</table>
</div>
<!-- #include file="footer.asp" -->
</div>
</body>
</html>



And _form.asp



<%
Sub showPage
if Server.HtmlEncode(request("submit")) = "" then
showAsk
else
showThanks
end if
End Sub

'**** edit this sub
Sub showAsk
%>
<form name="theform" action="<%= gsSN %>" method="post">
<table cellpadding="1" cellspacing="2" border="0" width="100%">
<tr valign="top">
<td>
<table cellpadding="1" cellspacing="2" border="0">
<%'**** edit from here ****%>
<tr>
<td colspan="2">To affiliate your school, we must have an authorised representative of the school complete and submit the details below.<br /><br />
Once interest is registered by a school, we will contact the school with the details required to become affiliated with MySchoolShop Limited.
We need things like the school bank account details, and in return we would like the school to promote our site on the school website and in
their newsletter.<br /><br />
At the end of each month, we will be able to provide each school a list of auctions for their school that occurred during that month. This becomes the basis of the payment to the school.<br /><br />
If you are a parent or friend of the school and would like your favourite school to benefit from people using this site, please refer the school
to this page by sending the URL at the top of this page and emailing it to the school. </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr valign="top">
<td valign="middle" class="aucNormal"><div align="right"><strong>Your School Name: </strong>&nbsp;</div></td>
<td class="aucNormal"><input type="text" name="School_Name" size="50" maxlength="100"></td>
</tr>
<tr valign="top">
<td valign="middle" class="aucNormal"><div align="right"><strong>School Email Address:</strong>&nbsp;</div></td>
<td class="aucNormal"><input type="text" name="School_Email" size="50" maxlength="75"></td>
</tr>
<tr valign="top">
<td valign="middle" class="aucNormal"><div align="right"><strong>Contact Name:</strong>&nbsp;</div></td>
<td class="aucNormal"><input type="text" name="Contact_Name" size="50" maxlength="100"></td>
</tr>
<tr valign="top">
<td valign="middle" class="aucNormal"><div align="right"><strong>Contact Phone:</strong>&nbsp;</div></td>
<td class="aucNormal"><input type="text" name="Contact_Phone" size="50" maxlength="100"></td>
</tr>
<tr valign="top">
<td valign="top" class="aucNormal"><div align="right"><strong>Comments:</strong>&nbsp;</div></td>
<td class="aucNormal"><textarea name="Comments" rows="10" cols="51"></textarea></td>
</tr>
<tr>
<td class="aucNormal"></td>
<td><img src="regVerify.asp" vspace="2" /></td>
</tr>
<tr>
<td valign="middle" class="aucNormal"><div align="right"><strong>Verification Code:</strong>&nbsp;</div></td>
<td valign="middle"><input type="text" name="fldverification" size="25" maxlength="25" > Please type the code above</td>
</tr>
<tr>
<td class="aucNormal">&nbsp;</td>
<td class="aucNormal"><input type="submit" name="submit" value="Submit" /></td>
</tr>
<%'**** edit to here ****%>
</table>
</td>
</tr>
</table>
</form>
<%
End Sub

'**** edit this sub
Sub showThanks
dim sBody, theKey, sFrom
%>
<table cellpadding="1" cellspacing="2" border="0" width="100%">
<%'**** edit from here ****%>
<tr valign="top">
<td width="50"><img src="/images/icons/contact2.gif"></td>
<td width="100%" class="aucTitle" align="left">School Sign-up</td>
</tr>
<tr>
<td class="aucNormal" colspan="2">
<hr>
Thanks for starting the sign-up process for your school! We'll be in contact very soon.
</td>
</tr>
<%'**** edit to here ****%>
</table>
<%
sBody = ""
for each theKey in request.form
if request.form(theKey) <> "" and theKey <> "submit" then
sBody = sBody & theKey & " : " & request.form(theKey) & " " & vbCrLf
end if
next

if request.form("email") = "" then
sFrom = Application("auctionemailadmin")
else
sFrom = request.form("email")
end if

'**** edit email-school-reg.txt
aucSendEmail sFrom, sFrom, Application("auctionemailadmin"), sBody, "email-school-reg.txt"
End Sub
%>


Hopefully that doesn't take up to much room! :p

The validation only needs to check that there is something in the fields and captcha will take care of any spammers hopefully. The email resulting from that script appears to have no line breaks or any sort of formatting at all. And it also displays the captcha code used to submit which is not needed but I see no way of changing any of that???

Any help much appreciated!

Cheers

lemusa
02 Feb 2011, 11:51 PM
Anyone?


15 characters