Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit Form With E-mail Confirmation help needed

Status
Not open for further replies.

Enkrypted

Technical User
Sep 18, 2002
663
US
I have this posted in the ASP section as well since the pages are ASP, but I need some help getting this to work. The following image is the screen we input information in when we take the customer information:

main.jpg


The following code is for the 2 buttons

Code:
    <CENTER>
    <input type="button" value="Submit" id="btnSubmit" name="btnSubmit" onClick="CheckWholeForm();">
    &nbsp
    &nbsp
    <form name="form1" method="post" action="quoteconfirm.php">
  <input type="submit" name="Submit" value="E-mail Confirmation">
</form>
    </CENTER>

I created a form (quoteconfirm.php) to handle the e-mail portion of it

Code:
<%

Set oMail = Server.CreateObject("CDO.Message") 
Set oMailConfig = Server.CreateObject ("CDO.Configuration") 

oMailConfig.Fields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "localhost" 
oMailConfig.Fields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25 
oMailConfig.Fields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 1 
oMailConfig.Fields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")[/URL] = 60 
oMailConfig.Fields.Update 

Set oMail.Configuration = oMailConfig 
oMail.From = "administrator@sharperimpressionspainting.com"
oMail.To = "test@sharperimpressionspainting.com"
oMail.Subject = "Sharper Impressions Painting Quote Confirmation"
oMail.HTMLBody = "Here goes the email body..."
oMail.Send 

Set oMail = Nothing 
Set oMailConfig = Nothing 

%>

I'm not sure if the existing code on the page is redirecting it to the submit function before it has a chance to e-mail the information.

On the regular submit button, it says that on click it goes to the checkwholeform function. I know that it checks to make sure all necessary fields are filled in and then submits it. Here is the code for that:

Code:
function CheckWholeForm() 
{
  document.QISheetForm.btnSubmit.disabled = true;
  varCheck = true;

  // Check username
  if (document.QISheetForm.QILastName.value == 0)
  {
       alert("Last name cannot be blank.\n");
       document.QISheetForm.QILastName.focus();
       varCheck = false;
  }
  else if ((document.QISheetForm.QIHomeNumber.value == 0) && (document.QISheetForm.QIWorkNumber.value == 0) && (document.QISheetForm.QICellNumber.value == 0))
  {
       alert("You must Enter at least one phone number.\n");
       document.QISheetForm.QIHomeNumber.focus();
       varCheck = false;
  }

  else if (document.QISheetForm.QIMakeApptLater.value == 0)
  {
    if (document.QISheetForm.QIAssignedTo.value == 0)
    {
         alert("Please select someone to assign this QI to.\n");
         document.QISheetForm.QIAssignedTo.focus();
         varCheck = false;
    }
  
    else if (document.QISheetForm.QIScopeOfWork.value == 0)
    {
         alert("Scope Of Work cannot be blank.\n");
         document.QISheetForm.QIScopeOfWork.focus();
         varCheck = false;
    }
    else if (document.QISheetForm.QIAddress1.value == 0)
    {
         alert("Address 1 cannot be blank.\n");
         document.QISheetForm.QIAddress1.focus();
         varCheck = false;
    }

    else if (document.QISheetForm.QICity.value == 0)
    {
         alert("City cannot be blank.\n");
         document.QISheetForm.City.focus();
         varCheck = false;
    }
    else if (document.QISheetForm.QIState.value == 0)
    {
         alert("You must select a State.\n");
         document.QISheetForm.QIState.focus();
         varCheck = false;
    }
  
    else if (isDate(document.QISheetForm.QIApptDate.value) == false)
    {
         //alert("The Appointment Date is not valid.\n");
         document.QISheetForm.QIApptDate.focus();
         varCheck = false;
    }

  }

        
  if (varCheck) 
  {

     document.QISheetForm.submit();
  } 
  else 
  {
    document.QISheetForm.btnSubmit.disabled = false;  
     return false;

The only other code that I think handles this is located on a different page. Here is some of the code for that:

Code:
<%
If QISheetFormSubmitted = 1 THEN
'Response.Write "QIID: " & QIID
    Response.Write "Adding Customer to the database<br><br>This screen should not appear for more than 30 seconds."
    If Len(QIApptDate) < 1 Or Len(QIApptTime) < 1 Or QIMakeApptLater = 1 THEN
      QIApptTimeComplete = "Null"
    Else
      QIApptTimeComplete = "'" & QIApptDate & " " & QIApptTime & "'"
    END IF

[COLOR=red]The code that follows this is the code that throws all the information into the SQL Database, so I will not post all that. The code the follows that is here:[/color]

elseif QISheetFormSubmitted = 2 THEN    

    strFirst=QIFirstName
    firstLen=Len(strFirst)
    strLast=QILastName
    lastLen=Len(strLast)
    strHome=QIHomeNumber
    homeLen=Len(strHome)
    strWork=QIWorkNumber
    workLen=Len(strWork)
    strCell=QICellNumber
    cellLen=Len(strCell)

    
    if homeLen > 1 then
        if firstLen > 1 then
            if lastLen > 1 then
                sqlSTR2 = "Select FirstName,LastName from Customer Where FirstName='" & NoApos(strFirst)& "' and LastName='" & NoApos(strLast) & "' and HomePhone='" & NoApos(strHome) & "'"
            else            
                sqlSTR2 = "Select FirstName,LastName from Customer Where FirstName='" & NoApos(strFirst) & "' and HomePhone='" & NoApos(strHome) & "'"
            end if
        else
            sqlSTR2 = "Select FirstName,LastName from Customer Where HomePhone='" & NoApos(strHome) & "'"
        end if
    elseif workLen > 1 then
        if firstLen > 1 then
            if lastLen > 1 then
                sqlSTR2 = "Select FirstName,LastName from Customer Where FirstName='" & NoApos(strFirst)& "' and LastName='" & NoApos(strLast) & "' and WorkPhone='" & NoApos(strWork) & "'"
            else            
                sqlSTR2 = "Select FirstName,LastName from Customer Where FirstName='" & NoApos(strFirst) & "' and WorkPhone='" & NoApos(strWork) & "'"
            end if
        else
            sqlSTR2 = "Select FirstName,LastName from Customer Where WorkPhone='" & NoApos(strWork) & "'"
        end if
    
    elseif cellLen > 1 then
        if firstLen > 1 then
            if lastLen > 1 then
                sqlSTR2 = "Select FirstName,LastName from Customer Where FirstName='" & NoApos(strFirst)& "' and LastName='" & NoApos(strLast) & "' and CellPhone='" & NoApos(strCell) & "'"
            else            
                sqlSTR2 = "Select FirstName,LastName from Customer Where FirstName='" & NoApos(strFirst) & "' and CellPhone='" & NoApos(strCell) & "'"
            end if
        else
            sqlSTR2 = "Select FirstName,LastName from Customer Where CellPhone='" & NoApos(strCell) & "'"
        end if

    
    elseif firstLen > 1 then
        if lastLen > 1 then
            sqlSTR2 = "Select FirstName,LastName from Customer Where FirstName='" & NoApos(strFirst)& "' and LastName='" & NoApos(strLast) & "'"
        else
            sqlSTR2 = "Select FirstName,LastName from Customer Where FirstName='" & NoApos(strFirst) & "'"
        end if
    elseif lastLen > 1 then
            sqlSTR2 = "Select FirstName,LastName from Customer Where LastName='" & NoApos(strLast) & "'"
    end if
    'response.write sqlStr
    rsA.Open sqlSTR2
    
    
            If NOT rsA.EOF Then
                Session("CustomerFound")="yes"
                rsA.Close
                Response.Redirect("default.asp?page=NEWQI")        
            End IF
    
    Session("CustomerFound")="no"
    Session("CustomerFirst")=QIFirstName
    Session("CustomerLast")=QILastName
    Session("CustomerHome")=QIHomeNumber
    Session("CustomerWork")=QIWorkNumber
    Session("CustomerCell")=QICellNumber
    Response.Redirect("default.asp?page=NEWQI")
    
End If

%>

So somewhere from where the Submit button function is and here, I have to find a way to make it send an e-mail with the Customer Information we type in the fields in the image above. I would prefer to have a button like the one in the image (E-mail Confirmation) as not all our customers provide us with e-mail addresses. I'm just having difficulty getting this to work.

Enkrypted
A+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top