Click to See Complete Forum and Search --> : Skip Registration Help


coopASP
04-20-2010, 09:20 PM
I am working on a website (I'm a ASP Novice)

Currently it is setup so that visitors that want to download a PDF file, can do so, only after they have either completed a full registration or an email registration.

I need to know how to properly code the register/index.asp page so that visitors looking to download a file can click on a link that reads "skip registration" and it will allow them to skip the registration altogether and go directly to the file they were intending to download initially.

In effect giving them 3 options:

Full Registration (This option already in place)
Email Only Registration (This option already in place)
Skip Registration (This option NEED ASSISTANCE)

The website is LightingControls.com

The page in need of help is Lightingcontrols.com/register/index.asp

Please Assist.
Thanks
CoopASP

yamaharuss
04-21-2010, 06:35 PM
You need to explain your setup further. If it's just a file they are downloading then just
<a href="http://yoursite/yourfile.pdf">Skip Registration</a>

You can't do both - restrict the file from download until registered AND download without registering. What's the point?

coopASP
04-21-2010, 07:08 PM
Yamaharuss,

Thanks for the reply.

Actually, WHY they are deciding to allow visitors to either download the file after registering or allow them to skip registration altogether, is out of my hands.

I believe it's because they still want to grab as many sign-ups as possible, but, there have been a few complaints so, they're implementing the "skip" option.

Currently the way it works it; if the user is signed in, they can download one of 4 PDF/DOC files directly from the homepage. If the user is not signed in, after clicking on the PDF/DOC file, they are automatically redirected to the Registration page where they are prompted to register.

We're attempting to add a Skip Registration link to allow the user to download the file they initially clicked on, on the homepage.

The coding is structured using "If, Else, Else If" procedures. I can't figure out how to code the Registration Page to allow the user to download the file without registering.

All that is require to register is an email address.

I can't figure out how to trick the page into thinking that a valid email address has been input, when the user clicks on the "skip registration" link.

Any help?

yamaharuss
04-22-2010, 06:30 AM
You still didn't explain how the link to the PDF is setup. You say they are redirected after clicking on the pdf file... HOW are you redirecting them?

The only way possible to require a login when clicking on a PDF link would be to use some sort of directory security on the server.

If I click a link to a pdf file, it will either load the pdf in the browser or prompt me to download it. The browser doesn't know to perform a different task with a file type of pdf.

Show the code, I did not see a link to your PDF/DOC file anywhere

coopASP
04-22-2010, 02:03 PM
Thanks for stickin with me Yamaha. I appreciate the help.

On the lightingcontrols.com homepage, under "system overview" there is a section of links that allow the user to download a PDF/DOC if they are signed in. If they aren't signed in and they click one of the links, it will redirect them to a Register page where they must, at minimum, enter an email address to be able to retrieve the PDF/DOC they initially clicked on, on the homepage.

Please see coding of 3 pages below:

Homepage:

<%'--START--META DATA%>
<!--#include virtual="utility/metadata/keyWords.asp"-->
<%'--START--META DATA%>

<%
pageColor_Main = "#009933"
pageColor_Opposite = "#ffffff"
pageColor_Sub1 = "#808080"
pageColor_Sub2 = "#C8CBCE"
pageColor_HighLight = "#EAEDF0"

pageTitle = "Lighting Control &amp; Design - "
pageSubTitle = ""

pageTitle = pageTitle & pageSubTitle & " 100% Digital Lighting Controls.."

mainPageUrl = Request.ServerVariables("URL")
topMargin = "0"
leftMargin = "16px"
sheetHeaderWidth = "750px"
sheetTitle = "/products/images/sheetHeader_Downloads.gif"
sheetSubTitle = "/products/images/sheetHeader_Support.gif"

leftNavigationWidth = "200px"

how_many_ads = 6
seconds = DatePart("s",Now())
ad = seconds Mod how_many_ads
ad = ad + 1
%>
<html>
<head>

<img src="images/indexpg/system.jpg" width="262" height="29">
<p class="quikNav"><a title="pdf" target="LCD" href="/products/downloadfile.asp?/productcatalog/downloads/lcd_brochures/LCD_brochure_corporate.pdf">Product Overview</a></p>
<p class="quikNav"><a title="pdf" target="LCD" href="/products/downloadfile.asp?/productcatalog/downloads/lcd_guides/LCD_guide_system_design.pdf">System Design Guide</a></p>
<p class="quikNav"><a title="pdf" target="LCD" href="/products/downloadfile.asp?/digitalcatalog/downloads/LCD_catalog_corporate.pdf">Product Catalog</a></p>
<p class="quikNav"><a title="doc" target="LCD" href="/products/downloadfile.asp?/productcatalog/downloads/lcd_guides/LCD-16515_RP.doc">System Specification</a></p>
<p class="quikNav"><a href="http://lightingcontrols.com/productcatalog/downloads/index.asp#TechSheets">Product Cut Sheets</a></p>
<p class="quikNav"><a href="http://lightingcontrols.com/productcatalog/downloads/index.asp#products">Product Manuals</a></p>
<p class="quikNav">Download installation manuals and hook-up instructions for GR 2400 lighting control products.
</p>




Register Page: (where the visitor is redirected if they aren't logged in and attempt a PDF/DOC download.)

<%
isDownloadRequest=True
ErrorMessage = ""

If Request.QueryString("errorMsg") <>"" then
ErrorMessage = Request.QueryString("errorMsg")
End If

If trim(Request.Form("camefrom")) <>"" then
CameFrom = Request.Form("camefrom")
ElseIf Request.QueryString("camefrom")<>"" Then
CameFrom = Request.QueryString("camefrom")
ElseIf Request.QueryString<>"" Then
If Left(Request.QueryString,1)="q" Then
isDownloadRequest=False
CameFrom="/"
End If
CameFrom = Request.QueryString
ElseIf Request.ServerVariables("HTTP_REFERER")<>"" Then
CameFrom = Request.ServerVariables("HTTP_REFERER")
Else
CameFrom = "/"
isDownloadRequest=False
End If

Guest = trim(Request.Cookies("Guest"))

If Guest="" or Guest="GUEST" then
Response.Cookies("Guest") = "GUEST"
Response.Cookies("UserName") = "GUEST"
Response.Cookies("Guest").Expires = #Jan 1,1998#
Response.Cookies("UserName").Expires = #Jan 1,1998#
Guest = "GUEST"
End if

isUnity = True 'registration is required
unity="y"
'unity = Request.QueryString("unity")
'If unity="y" Then isUnity = True
%>
<html>
<head>
<title>Lighting Control &amp; Design: registration.</title>
<meta http-equiv="Content-Type" content="text/asp; charset=iso-8859-1">

<script language="JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}

function validateEmail()
{
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
var elementValue = document.getElementById('emailaddress').value;

if( emailPattern.test(elementValue) != true)
{
alert("Invalid email address");
return false;
}

return true;

}


//-->
</script>
<link rel="stylesheet" href="../stylesheets/main.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" onLoad="MM_preloadImages('../navigation/images/main_over_06.gif','../navigation/images/main_over_07.gif','../navigation/images/main_over_08.gif','../navigation/images/main_05.gif')" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<%'--START--HEADER TABLE OBJECT%>
<table cellpadding="0" cellspacing="0" border="0" id="tbl_Header" style="width:100%;">
<tr>
<td>
<a name="TopOfPage"></a>

<%'--START--FOOTER LAYER OBJECT%>
<!--#include virtual="/utility/navigation/pageHeader_Navitation_Green.asp"-->
<%'--END--FOOTER LAYER OBJECT%> </td>
</tr>
</table>
<%'--END--HEADER TABLE OBJECT%>

<table width="750" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="4"><a name="top"></a><img src="/main/images/quick_registration.gif" width=350 height=40></td>
</tr>
<tr>
<td width="20">&nbsp;</td>
<td valign="top" width="150">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<br>
<p><a href="full_registration.asp?<%=CameFrom%>">Full Registration</a></p>

<% If Guest <> "" and Guest <> "GUEST" Then %>
<p><a href="signout.asp">Sign Out</a></p>
<% End If %>
</font>
</td>
<td width="20">&nbsp;</td>
<td width="560" valign="top">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<br>
<% If Guest = "" or Guest = "GUEST" then %>
Please enter
a valid email address to access the resource you requested.
<form name="registation" action="checkregistration_CDOSYS.asp" method="post" onSubmit="return validateEmail('emailaddress' ); ">
<input type="hidden" name="camefrom" value="<%=CameFrom%>">
<input type="hidden" name="unity" value="<%=unity%>">
<br><br>
<b>* Email Address</b> <input type="text" id="emailaddress" name="emailaddress" value="" size="50" maxlength="64"><br>
<br>
<input type="submit" name="submitEmailaddress" value="Register">
<br>
<div align="center">
<font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" color="#FF0000">
<%=ErrorMessage%>
</font>
</div>
</form>
<% Else %>
<p><b>Welcome, <%=Request.Cookies("UserName")%>! Thank you for registering.</b></p>
<br>
To continue, <a href="/products/downloadfile.asp?<%=CameFrom%>">click here</a><br>
To update your profile, <a href="updateprofile.asp?<%=CameFrom%>">click here.</a><br>
<% End If %>

</font>
</td>
</tr>
</table>
<!--#include virtual="/includes/siteFooter.asp"-->
</body>
</html>


One more page to follow
Thanks
coopASP

coopASP
04-22-2010, 02:05 PM
Check Registration Page (the page of codes that the Register Page uses to validate email address to determine if a user has logged in or not before granting access to a file.)

<!--#include virtual="/Utility/db_ConnectionString.asp"-->
<!--#include virtual="/Utility/db_sanitize.asp"-->
<%
Function sendThankYouEmail(emailAddress)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
bodyHTML = fso.OpenTextFile(Server.Mappath("thank_you.html")).ReadAll

bodyHTML = Replace(bodyHTML,"%%email%%",emailAddress)
bodyHTML = Replace(bodyHTML,"%%name%%",emailaddress)
'bodyHTML = Replace(bodyHTML,"%%FID%%",iCurrentValue)

Set mymail = CreateObject("CDO.Message")
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.lightingcontrols.com"
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")="mailrelay"
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")="mr091"
mymail.Configuration.Fields.Update
mymail.to = emailAddress
mymail.From = "thankyou@lightingcontrols.com"
mymail.Subject = "Thank you for your online registration!"
mymail.BCC = "lcd_dougm@hotmail.com"
mymail.HTMLbody = bodyHTML
mymail.Send
Set mymail = Nothing
End Function

Function sendRegistrationAlert(emailAddress)
Dim ObjCdo1
Set ObjCdo1 = CreateObject("CDO.Message")
ObjCdo1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
ObjCdo1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.lightingcontrols.com"
ObjCdo1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjCdo1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1
ObjCdo1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")="mailrelay"
ObjCdo1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")="mr091"
ObjCdo1.Configuration.Fields.Update
ObjCdo1.From = "inews@lightingcontrols.com"
'TAKE OUT
ObjCdo1.To = "lcd_dougm@hotmail.com"
ObjCdo1.Subject = "Thank you for your online registration!"
ObjCdo1.HTMLbody = "New registration received from website: " & emailAddress
ObjCdo1.Send
Set ObjCdo1 = Nothing
End Function
'==============================='

If Trim(Request.Form("camefrom")) <>"" then
CameFrom = Request.Form("camefrom")
ElseIf Request.QueryString("camefrom")<>"" Then
CameFrom = Request.QueryString("camefrom")
ElseIf Request.QueryString<>"" Then
CameFrom = Request.QueryString
Else
CameFrom = "/"
End If

unity = Request.Form("unity")
If unity="" Then Request.QueryString("unity")
If unity="" Then unity = "n"

'this cannot be blank
emailAddress=Trim(LCase(Request.Form("emailaddress")))

'The below items are not factored into the registration and should be. Needs to be updated when the site is rewritten.
varName = Trim(LCase(Request.Form("varName")))
varCompany = Trim(LCase(Request.Form("varCompany")))
varAddress = Trim(LCase(Request.Form("varAddress")))
varCity = Trim(LCase(Request.Form("varCity")))
varState = Trim(LCase(Request.Form("varState")))
varZip = Trim(LCase(Request.Form("varZip")))
varPhone = Trim(LCase(Request.Form("varPhone")))
varCell = Trim(LCase(Request.Form("varCell")))
varFax = Trim(LCase(Request.Form("varFax")))
varFirmtype = Trim(LCase(Request.Form("varFirmtype")))
varContactme = Trim(LCase(Request.Form("varContactme")))
varOptin = Trim(LCase(Request.Form("varOptin")))

'emailAddress=Trim(sanitize-string(LCase(Request.Form("emailaddress"))))
If isNull(emailAddress) or emailAddress="" Then Response.Redirect("index.asp?unity=" & unity & "&camefrom=" & CameFrom)
If InStr(LCase(emailAddress), "/*") <> 0 Then
Response.Redirect("index.asp?unity=" & unity & "&camefrom=" & CameFrom & "&errorMsg=Email address contains invalid string: /*")
ElseIf InStr(LCase(emailAddress), "union") <> 0 Then
Response.Redirect("index.asp?unity=" & unity & "&camefrom=" & CameFrom & "&errorMsg=Email address contains invalid string: UNION")
ElseIf InStr(LCase(emailAddress), "select ") <> 0 Then
Response.Redirect("index.asp?unity=" & unity & "&camefrom=" & CameFrom & "&errorMsg=Email address contains invalid string: SELECT")
ElseIf InStr(LCase(emailAddress), "drop ") <> 0 Then
Response.Redirect("index.asp?unity=" & unity & "&camefrom=" & CameFrom & "&errorMsg=Email address contains invalid string: DROP")
ElseIf InStr(LCase(emailAddress), "--") <> 0 Then
Response.Redirect("index.asp?unity=" & unity & "&camefrom=" & CameFrom & "&errorMsg=Email address contains invalid string: --")
ElseIf InStr(LCase(emailAddress), "insert ") <> 0 Then
Response.Redirect("index.asp?unity=" & unity & "&camefrom=" & CameFrom & "&errorMsg=Email address contains invalid string: INSERT")
ElseIf InStr(LCase(emailAddress), "delete ") <> 0 Then
Response.Redirect("index.asp?unity=" & unity & "&camefrom=" & CameFrom & "&errorMsg=Email address contains invalid string: DELETE")
ElseIf InStr(LCase(emailAddress), "xp_") <> 0 Then
Response.Redirect("index.asp?unity=" & unity & "&camefrom=" & CameFrom & "&errorMsg=Email address contains invalid string: xp_")
ElseIf InStr(LCase(emailAddress), "truncate ") <> 0 Then
Response.Redirect("index.asp?unity=" & unity & "&camefrom=" & CameFrom & "&errorMsg=Email address contains invalid string: TRUNCATE")
ElseIf InStr(LCase(emailAddress), ";") <> 0 Then
Response.Redirect("index.asp?unity=" & unity & "&camefrom=" & CameFrom & "&errorMsg=Email address contains invalid string: ;")
ElseIf InStr(LCase(emailAddress), "'") <> 0 Then
Response.Redirect("index.asp?unity=" & unity & "&camefrom=" & CameFrom & "&errorMsg=Email address contains invalid string: '")

Else
'must synchronize with web database for backwards compatibility
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open loosecannon_connector 'string_Connection
Set rs = Server.CreateObject("ADODB.Recordset")

StrSQL = "dbo.lcd_update_profile '" & emailAddress & "',"
StrSQL = StrSQL & "'" & emailAddress & "',"
StrSQL = StrSQL & "'',"
StrSQL = StrSQL & "'',"
StrSQL = StrSQL & "'',"
StrSQL = StrSQL & "'',"
StrSQL = StrSQL & "'',"
StrSQL = StrSQL & "'',"
StrSQL = StrSQL & "'',"
StrSQL = StrSQL & "'',"
StrSQL = StrSQL & "'',"
StrSQL = StrSQL & "''"
If Request.Form("Guest") <> "" AND Request.Form<>"GUEST" then
StrSQL = StrSQL & ",'" & Request.Form("Guest") & "'"
End if

set rs = Conn.Execute(StrSQL)

Response.Cookies("Guest") = emailaddress
Response.Cookies("Name") = emailaddress
Response.Cookies("UserName") = emailaddress
Response.Cookies("Guest").Expires = Now() + 10000
Response.Cookies("UserName").Expires = Now() + 10000
Response.Cookies("Name").Expires = Now() + 10000


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''
'NEED TO GET IT WORKING WITH STORED PROCEDURE - CAN PUT THIS BACK IN LATER
Set dbo = Server.CreateObject("ADODB.Connection")
dbo.ConnectionTimeout = 90
dbo.Open loosecannon_connector

Set rso = Server.CreateObject("ADODB.Recordset")
rso.Open "SELECT fID, fEmailAddress, fStatus FROM tEmailAddresses WHERE fEmailAddress='" & emailAddress & "';",dbo,3,1,1

If rso.BOF and rso.EOF Then

'new registrant, ask if qualified and interested in survey
dbo.Execute "INSERT INTO tEmailAddresses (fStatus,fEmailAddress,fSource,fDatabaseSource,fContactSource) VALUES('F','" & emailAddress & "','Web Registration','Web','Web Registration');"

Dim rsIdentity
Set rsIdentity = dbo.Execute("SELECT fID FROM tEmailAddresses WHERE fEmailAddress = '" & emailAddress & "'")
Dim iCurrentValue
iCurrentValue = rsIdentity(0)
dbo.Execute "INSERT INTO tNewsletterLists (fNewsletterPartnerID,fEmailAddressID) VALUES (2,'" & iCurrentValue & "');"

sendRegistrationAlert(emailAddress)
sendThankYouEmail(emailAddress)


If Instr(LCase(CameFrom),"silverbullet")>0 Then
Response.Redirect("silverbullet_survey.asp?unity=" & unity & "&camefrom=" & CameFrom)
'Response.Write "(" & emailAddress & ") going to silverbullet_survey.asp...:)"
Else
Response.Redirect("selectsurvey.asp?unity=" & unity & "&camefrom=" & CameFrom)
'Response.Write "(" & emailAddress & ") going to selectsurvey.asp...:)"
End If
Else
dbo.Execute "UPDATE tEmailAddresses SET fStatus = 'A' WHERE fEmailAddress = '" & emailAddress & "'"

'sendRegistrationAlert(emailAddress)
'sendThankYouEmail(emailAddress)

'redirect to requested file
Response.Redirect("/products/downloadfile.asp?unity=" & unity & "&camefrom=" & CameFrom)
End If
End If
'End If


%>

Any help?
CoopASP

yamaharuss
04-22-2010, 03:59 PM
You do realize that the initial link on the home page contains a link to the PDF file, yes?

All I had to do was parse the querystring and go directly to

http://lightingcontrols.com/productcatalog/downloads/lcd_guides/LCD_guide_system_design.pdf

If that's how you want it to be that's fine.. and in that case, on your /register/index.asp page just place this code beneath your registration form.

<%
strFile = request.querystring("camefrom")
%>
Don't want to register? That's OK, just <a href="<%=strFile%>">click here</a> for the file

coopASP
04-22-2010, 08:40 PM
Yamaharuss - Thank you for the help!!

The code you provided worked perfect!

coopASP