|
<%
'dimension variables
dim formError, blankFieldError, emailError, passwordError, usernameError, strSQL, page, busType
page = Request.ServerVariables("Script_name")
formError = false
blankFieldError = false
emailError = false
passwordError = false
usernameError = false
'first, test to see if this request is from a submission..
if request.Form("submission") = "1" then
'..it is so we must process and save the data to the database
'Ensure all mandatory fields have values.
'Checks are: ensuring email address looks valid
'Removing "http://" from website addresses
'Ensure the user name has not already been taken
'Ensure both password fields contain the same string
'As of 19 May 03, allows user to add information to different locations, represented by
'different tables in the database. Therefore, first thing to do is determine which table
'we are dealing with
dim objRSLoc, siteTableName, siteName
set objRSLoc = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT business_table, name FROM sites WHERE id =" & Trim(Request.Form("location"))
strSQL = strSQL & " ORDER BY name;"
objRSLoc.Open strSQL, MM_business_list_STRING, adOpenForwardOnly,adLockReadOnly, adCmdText
objRSLoc.MoveFirst
siteTableName = objRSLoc("business_table")
siteName = objRSLoc("name")
objRSLoc.Close
set objRSLoc = nothing
'Start with blank fields
if (Trim(Request.Form("busname")) = "") or (Trim(Request.Form("address1")) = "") or (Trim(Request.Form("address2")) = "") or (Trim(Request.Form("address3")) = "") or (Trim(Request.Form("address4")) = "") then
blankFieldError = true
formError = true
end if
if (Trim(Request.Form("postcode5")) = "") or (Trim(Request.Form("timesopen")) = "") or (Trim(Request.Form("daysopen")) = "") or (Trim(Request.Form("telephone")) = "") or (Trim(Request.Form("contact")) = "") then
blankFieldError = true
formError = true
end if
if (Trim(Request.Form("email")) = "") or (Trim(Request.Form("position")) = "") or (Trim(Request.Form("yearstrading")) = "") or (Trim(Request.Form("furtherinfo")) = "") then
blankFieldError = true
formError = true
end if
if (Trim(Request.Form("username")) = "") or (Trim(Request.Form("password1")) = "") or (Trim(Request.Form("password2")) = "") then
blankFieldError = true
formError = true
end if
'check e.mail address is valid
dim emailAddress
emailAddress = Trim(Request.Form("email"))
'e.mailAddress must contain an @ symbol and at least one period after it
dim atLocation
atLocation = InStr(emailAddress, "@")
if atLocation <> 0 then
'get the string after the @ symbol
dim afterAt
afterAt = Right(emailAddress, (Len(emailAddress) - atLocation))
dim periodLocation
periodLocation = InStr(afterAt, ".")
if periodLocation = 0 then
formError = true
emailError = true
end if
else
formError = true
emailError = true
end if
'ensure the user name is free
'to do this, we must check the database
Dim objRSCheckUsername, objCmdCheckUsername
Set objRSCheckUsername = Server.CreateObject("ADODB.Recordset")
Set objCmdCheckUsername = Server.CreateObject("ADODB.Command")
objCmdCheckUsername.ActiveConnection = MM_business_list_STRING
objCmdCheckUsername.CommandText = "SELECT user_name FROM " & siteTableName & " WHERE user_name = '" & Trim(Request.Form("username")) & "'"
objCmdCheckUsername.CommandType = adCmdText
objRSCheckUsername.open objCmdCheckUsername
'if the recordset is not empty, the user name has already been used
if not objRSCheckUsername.EOF then
usernameError = true
formError = true
end if
'close database connection
objRSCheckUsername.Close
Set objRSCheckUsername = Nothing
set objCmdCheckUsername = Nothing
'check passwords match
if Trim(Request.Form("password1")) <> Trim(Request.Form("password2")) then
passwordError = true
formError = true
end if
if formError = false then
'The information is fine, so save to database
'ensure all URLs are saved without http://
dim strURL
strURL = Trim(Request.Form("url"))
if ((InStr(strURL, "http://") <> 0) OR (InStr(strURL, "HTTP://") <> 0)) then
strURL = Right(strURL, (Len(strURL) - 7))
end if
'get the text for the business type
Dim objRSbusType, objCmdbusType
Set objRSbusType = Server.CreateObject("ADODB.Recordset")
Set objCmdbusType = Server.CreateObject("ADODB.Command")
objCmdbusType.ActiveConnection = MM_business_list_STRING
objCmdbusType.CommandText = "SELECT type_name FROM business_types WHERE type_id = '" & Trim(Request.Form("bus_type")) & "'"
objCmdbusType.CommandType = adCmdText
objRSbusType.open objCmdbusType
busType = objRSbusType("type_name")
objRSbusType.Close
set objRSbusType = nothing
set objCmdbusType = nothing
strSQL = "INSERT INTO " & siteTableName
strSQL = strSQL + " (business_name, address1, address2, address3, address4, postcode, "
strSQL = strSQL + "web_address, trade_hour, trade_days, telephone, fax, corr_name, email_address, "
strSQL = strSQL + "corr_pos, trade_years, notes, active, type_id, business_type, user_name, password) VALUES ("
strSQL = strSQL + "'" & Trim(Request.Form("busname"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("address1"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("address2"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("address3"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("address4"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("postcode5"))& "', "
strSQL = strSQL + "'" & strURL & "', "
strSQL = strSQL + "'" & Trim(Request.Form("timesopen"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("daysopen"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("telephone"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("faxno"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("contact"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("email"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("position"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("yearstrading"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("furtherinfo"))& "', "
strSQL = strSQL + "0, "
strSQL = strSQL + "" & Trim(Request.Form("bus_type")) & ", "
strSQL = strSQL + "'" & busType & "', "
strSQL = strSQL + "'" & Trim(Request.Form("username"))& "', "
strSQL = strSQL + "'" & Trim(Request.Form("password1"))& "'"
strSQL = strSQL + ")"
'open database connection
Dim objConn
Set objConn = Server.CreateObject("ADODB.Command")
objConn.ActiveConnection = MM_business_list_STRING
objConn.CommandText = strSQL
objConn.CommandType = adCmdText
objConn.Execute
'save data
'close database connection
Set objConn = Nothing
'send confirmation email
dim objCdoMail, strEmail
strEmail = "The business '"
strEmail = strEmail & Trim(Request.Form("busname"))
strEmail = strEmail & "' has been added to the " & siteName & " database under the "
strEmail = strEmail & Trim(Request.Form("bus_type"))
strEmail = strEmail & " category. "
set objCdoMail = Server.CreateObject("CDONTS.NewMail")
With objCdoMail
.From = "businesses@piperfiction.com"
.To = "ian@mowmow-design.co.uk"
.Subject = "Business added to " & siteName & " database"
.Body = strEmail
.Send
End With
set objCdoMail = nothing
'render confirmation message and end script
%>
Thank you for submitting your business listing on P2BL. As always,
we appreciate your support and hope we can help
spread the word about your business by making your details available 24 hours,
7 days per week.
Editing and updating your listing
Visit the "Edit business details" page to update your information.
Help using this service
Don't hesitate to contact us if you need any further information regarding P2BL
services.
Please ensure you check the details of your listing within the next 48hrs.
Add your business
to multiple categories
If you wish to have your business listed under other categories
upgrade to the enhanced listing.
Featured on the front
page
Your business featured on the front page of this site with
an article and photographs
Add 5 images to your
page
Include up to 5 images including a logo, pictures of your
shop front and products
Submitted to search
engines
Your page individually optimised and submitted to 5 top search
engines including Google.
Free banner advertisement
We'll design a free banner advertisement which will appear
on our listing pages and will be linked directly to your page
or web site.
199 web site 15% discount
You'll be entitled to a 15% discount on our 199 web site offer.
If you don't have a web site already, we'll design, build
and host one for you for £199.00 less 15%. Click
here to find out more about 199 web sites.
APPLY HERE FOR YOUR
ENHANCED LISTING
Click
here to continue using the site
<%
Response.End() 'called if the form was submitted successfully
end if
end if
'if we get here without calling Response.End(), the form needs rendering
%>
|