Click to See Complete Forum and Search --> : Need advice on ASP statement
kwilliams
10-29-2003, 10:37 AM
Hello,
I created an Online Employment Application that uses ASP, JavaScript 7 SQL Server2k. The applicant can submit their application by pressing a button, and this action goes to a page that emails our Personnel Division.
Once option on the app is for users to attach their resume. I'd like for the email that gets sent to the Personnel Division to either have a link to the user's resume, or simple text saying "No Resume". This is what I came up with so far:
<%
**//Apply variable to empty Resume field
var strURL = "http://www.douglas-county.com/Employment/redirectresume.asp?id=";
var strId = Session("MM_recordId");
//if resume field is not <NULL>
if (Session("MM_Resume") != "<NULL>"){
Session("No_Resume") = (strURL + strId);
}
//if resume field is <NULL>
else if (Session("MM_Resume") = "<NULL>")
{
Session("No_Resume") = "No Resume";
}
%>
...but for some reason, it's not working properly. I've been testing this on 2 applicants. Once has a resume, and the other does not. But sometimes the opposite string comes up for either. For example:
Joe Schmo has a resume on his application. When he clicks the "Submit New Application" button, which starts this ASP statement, the Personnel Dept. receives an email that says "No Resume".
But Judy Schmo did not attach a resume to her application. When she submits it though, the email gives a link from the ASP statement that says that she does have a resume.
I'm confused on why this works sometimes, and not others. Is there a way to abandon an individual Session Variable? I think that's where the problem may lie. Any and all suggestions would be great. Thanks.
chrismartz
11-08-2003, 06:10 PM
you did not end your if statement and you do not have then in there anywhere. this may not be the problem but thats all i can find
slyfox
11-18-2003, 07:00 AM
try
<%
**//Apply variable to empty Resume field
var strURL = "http://www.douglas-county.com/Employment/redirectresume.asp?id=";
var strId = Session("MM_recordId");
//if resume field is not <NULL>
if (Session("MM_Resume") != 0){
Session("No_Resume") = (strURL + strId);
}
//if resume field is <NULL>
else if (Session("MM_Resume") == 0)
{
Session("No_Resume") = "No Resume";
}
%>
OR this one
<%
**//Apply variable to empty Resume field
var strURL = "http://www.douglas-county.com/Employment/redirectresume.asp?id=";
var strId = Session("MM_recordId");
//if resume field is not <NULL>
if (Session("MM_Resume") != "<NULL>"){
Session("No_Resume") = (strURL + strId);
}
//if resume field is <NULL>
else if (Session("MM_Resume") == "<NULL>")
{
Session("No_Resume") = "No Resume";
}
%>
Look at:
else if (Session("MM_Resume") = "<NULL>")
Note that:
= "<NULL>")
should be:
== "<NULL>")
Hope this helps
slyfox
11-18-2003, 07:08 AM
By the way... the original poster of this question is using ASP - JScript and the "then" and "end if" is replaced with "{" and "}" aposed to ASP - VBScript
Back to basics:
You can also instead of the 0 I entered there try ""
Don't exactly know what your values passed thru looks like
kwilliams
11-18-2003, 09:46 AM
Hi slyfox,
Ok, I tried your second solution, and I'm coming up with the same problem. It does work, but the Session variable doesn't reset before the submittal when a resume has been added or deleted from that field. For instance:
Lets say that Joe Blow submits partial application without a resume initially, because it's incomplete. But he wan'ts to be considered for a new job. So he submits his online application without a resume. The Personnel Division receives an email with a link to his application, but "No Resume" listed where a link would be if he had a resume.
Then a week later, he gets the resume completed, and decides to update his application with his new resume. After he submits it, he clicks the "Submit Updated Application" button. But the Personnel Division sees "No Resume", instead of a link to his resume. But when he clicks the button again to submit his application, the link shows up to his resume.
This is the only problem with this solution. Is there a way to clear the session var Session("No_Resume") somehow before the ASP statement is read, and email is sent?
P.S. I've included the entire code of this page at the bottom of this email, including the ASP statement.
KWilliams
<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file="Connections/strConn.asp" -->
<script runat=server language="vbscript" src="ScriptLibrary/date_validation.vbs"></script>
<%
if(String(Session("App_Date")) != "undefined"){ cmdAppDate__varApp_Date = String(Session("App_Date"));}
if(String(Session("MM_Username")) != "undefined"){ cmdAppDate__varApp_ID2 = String(Session("MM_Username"));}
%>
<%
if (Session("MM_recordId") != null) { }
else {Response.Redirect("noaccess.asp")}
%>
<%
var rsNewApp1__MMColParam = "Seqno";
if(String(Request.QueryString("id")) != "undefined") {
rsNewApp1__MMColParam = String(Request.QueryString("id"));
}
%>
<%
var rsNewApp1__varApp_ID = "%";
if(String(Session("MM_Username")) != "undefined") {
rsNewApp1__varApp_ID = String(Session("MM_Username"));
}
%>
<%
var rsNewApp1__varPassword = "%";
if(String(Session("MM_Password")) != "undefined") {
rsNewApp1__varPassword = String(Session("MM_Password"));
}
%>
<%
var rsNewApp1 = Server.CreateObject("ADODB.Recordset");
rsNewApp1.ActiveConnection = MM_strConn_STRING;
rsNewApp1.Source = "SELECT * FROM dbo.Employment_App WHERE App_ID LIKE '"+ rsNewApp1__varApp_ID.replace(/'/g, "''") + "' AND Password LIKE '"+ rsNewApp1__varPassword.replace(/'/g, "''") + "' AND Seqno = "+ rsNewApp1__MMColParam.replace(/'/g, "''") + "";
rsNewApp1.CursorType = 0;
rsNewApp1.CursorLocation = 2;
rsNewApp1.LockType = 3;
rsNewApp1.Open();
var rsNewApp1_numRows = 0;
%>
<%
Session("MM_recordId") = rsNewApp1.Fields.Item("Seqno").Value;
Session("Last_Name") = rsNewApp1.Fields.Item("Last_Name").Value;
Session("First_Name") = rsNewApp1.Fields.Item("First_Name").Value;
Session("MM_Email") = rsNewApp1.Fields.Item("Email").Value;
Session("Last_Update_Date") = rsNewApp1.Fields.Item("Last_Update_Date").Value;
Session("Creation_Date") = rsNewApp1.Fields.Item("Creation_Date").Value;
Session("MM_Resume") = rsNewApp1.Fields.Item("Resume_Attach").Value;
%>
<%
var rsNewApp2__varApp_ID = "%";
if(String(Session("MM_Username")) != "undefined") {
rsNewApp2__varApp_ID = String(Session("MM_Username"));
}
%>
<%
var rsNewApp2 = Server.CreateObject("ADODB.Recordset");
rsNewApp2.ActiveConnection = MM_strConn_STRING;
rsNewApp2.Source = "SELECT * FROM dbo.Employ_Jobs WHERE App_ID LIKE '"+ rsNewApp2__varApp_ID.replace(/'/g, "''") + "'";
rsNewApp2.CursorType = 0;
rsNewApp2.CursorLocation = 2;
rsNewApp2.LockType = 3;
rsNewApp2.Open();
var rsNewApp2_numRows = 0;
%>
<%
var cmdAppDate = Server.CreateObject("ADODB.Command");
cmdAppDate.ActiveConnection = MM_strConn_STRING;
cmdAppDate.CommandText = "UPDATE dbo.Employment_App SET Application_Date = '"+ cmdAppDate__varApp_Date.replace(/'/g, "''") + "', Last_Update_Date = '"+ cmdAppDate__varApp_Date.replace(/'/g, "''") + "' WHERE App_ID = '"+ cmdAppDate__varApp_ID2.replace(/'/g, "''") + "' ";
cmdAppDate.CommandType = 1;
cmdAppDate.CommandTimeout = 0;
cmdAppDate.Prepared = true;
cmdAppDate.Execute();
%>
<%
//Apply variable to empty Resume field
var strURL = "http://www.douglas-county.com/Employment/redirectresume.asp?id=";
var strId = Session("MM_recordId");
var strResume = (rsNewApp1.Fields.Item("Resume_Attach").Value);
//if resume field is not <NULL>
if (strResume != "<NULL>"){
Session("No_Resume") = (strURL + strId);
}
//if resume field is <NULL>
else if (strResume == "<NULL>")
{
Session("No_Resume") = "No Resume";
}
%>
<SCRIPT LANGUAGE="VBSCRIPT" RUNAT="SERVER">
Response.Buffer = True
Const cdoSendUsingPickup = 1
Const strPickup = "c:\Program Files\Exchsrvr\mailroot\vsi 1\Pickup"
Set objSendMail = CreateObject("CDO.Message")
Set iConf = objSendMail.Configuration
With iConf.Fields
.item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPickup
.item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = strPickup
.Update
End With
With objSendMail
.To = "webmaster@douglas-county.com"
.From = Session("MM_Email")
.Subject = "New Application"
.TextBody = "APPLICANT'S INFORMATION" & vbcrlf & "First Name: " & Session("First_Name") & vbcrlf & "Last Name: " & Session("Last_Name") & vbcrlf & "App ID: " & Session("MM_Username") & vbcrlf & vbcrlf & "To view & print a copy of this new application, click the link below:" & vbcrlf & vbcrlf & "http://www.douglas-county.com/Employment/redirectapp.asp?id=" & Session("MM_recordId") & vbcrlf & vbcrlf & "To view & print a copy of their resume, click the link below:" & vbcrlf & vbcrlf & Session("No_Resume") & vbcrlf & vbcrlf & "(NOTE: If the link above only says www.douglas-county.com, then the applicant did not attach their resume to this application.)"
.Send
End With
Set objSendMail = Nothing
</SCRIPT>
<meta http-equiv="refresh" content="0;URL=thankyou.asp">
<%
rsNewApp1.Close();
%>
<%
rsNewApp2.Close();
%>
slyfox
11-18-2003, 01:28 PM
Session("No_Resume") = "";
I think... didn't study your code in detail