Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    New Coder
    Join Date
    Nov 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP Time stamp??

    Hello everyone I'm back again with yet another question... I am using an ASP script for form submission and I want it to grab the date and time when the form is submitted. Anyone have any ideas? Thanks

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    http://msdn.microsoft.com/library/de...riVBScript.asp

    On the left hand side open the "Reference" link and then the "Functions" link. Scroll down to the "Date" function in the right hand side.

  • #3
    New Coder
    Join Date
    Nov 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok but where in the ASP do I insert the two codes for date & time?

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How about in the code where you need it? If you want something more specific you have to provide more details.

  • #5
    New Coder
    Join Date
    Nov 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <%@language = "VBscript"%>
    <%
    Dim strError
    Response.Buffer = True
    If ScriptEngineMajorVersion < 2 Then
    ReportError "Host system needs scripting engine upgrade to use this script"
    End If
    Set objFM = CreateObject("Scripting.Dictionary")
    If IsObject(objFM) = False Then
    ReportError "Host system lacks component(s) required by this script"
    End If
    Set objMailx = CreateObject("CDONTS.Newmail")
    If IsObject(objMailx) = False Then
    ReportError "Host system lacks component(s) required by this script"
    End If
    Set objMailx = Nothing
    %>
    <%
    'aspmailer.asp by Tom Germain, Copyright 1998-1999
    'Version 1.0
    'tg@cgiware.com
    'Visit http://www.cgiware.com for latest version, documentation, and other resources
    'This is freeware - Use at your own risk. No warranties provided.
    'Redistribution of this program, in whole or in part, is strictly
    'prohibited without the expressed written consent of the author.
    'Custom programming available on hourly fee basis.
    %>

    <%'variables you can set start here%>
    <%
    strRcpt = "formmail@titanroofing.com" 'Put the address you want the form sent to here

    strFromVar = "E-Mail" 'If you want a reply-to email address to be taken from the form
    ' put the name of the input item here.

    strDefFrom = "formmail@titanroofing.com" 'Put a default, even fake, From address here

    strDefSubject = "Titan Roofing, Inc. Contact Form" 'Put the subject of the letter here. If an input item called
    'subject exists in the form, its value will be used instead.

    strRedirect = "Confirm.htm" 'Url to redirect to after a successful form submission. If an input item called
    'redirect exists in the form, its value will be used instead.

    %>
    <%'variables you can set end here%>

    <%
    ParseForm
    CheckForm
    If Len(strError) > 0 Then
    ReportError strError
    End If
    strOutX = SeqForm
    If Len(strOutX) < 1 Then
    strOutX = FormToString
    End If
    If Len(strOutX) < 1 Then
    ReportError "Submitted form is empty"
    End If
    strSubject = strDefSubject
    If objFM.Exists("TGsubject") Then
    strSubject = objFM.Item("TGsubject")
    End If
    strFrom = strDefFrom
    If Len(strFromVar) > 0 Then
    If objFM.Exists(strFromVar) Then strFrom = objFM.Item(strFromVar) End If
    End If
    SendMail strFrom,strRcpt,strSubject,strOutX
    If Len(strRedirect) > 0 Then
    Response.redirect(strRedirect)
    Response.End
    End If
    If objFM.Exists("TGredirect") = True Then
    If Len(objFM.Item("TGredirect")) > 0 Then
    Response.redirect(objFM.Item("TGredirect"))
    Response.End
    End If
    End If
    %>

    <!--*******SUCCESSFUL SUBMISSION RESPONSE - START*******-->
    <!--ADD YOUR OWN HTML TOP SECTION STARTING HERE-->
    <h1>Form Sent!</h1>
    Your request has been received and will be processed shortly.
    <!--ADD YOUR OWN HTML TOP SECTION UP TO HERE-->
    <!--*******SUCCESSFUL SUBMISSION RESPONSE - END********-->

    <%
    Credit
    Response.End
    %>
    <%
    Function IsValidEmail(Email)
    Dim Temp,Temp2
    strNotValid = "<br>Email address not valid"
    strTooLong = "<br>Email address too long"
    If Len(Email) > 100 Then
    ReportError strTooLong
    End If
    Email = LCase(Email)
    Temp = Split(Email,"@",2,1)
    If UBound(Temp) < 1 Then
    ReportError strNotValid
    End If
    Temp2 = Split(Temp(1),".",-1,1)
    If UBound(Temp2) < 1 Then
    ReportError strNotValid
    End If
    End Function
    %>
    <%
    Function SendMail(From,Rcpt,Subject,Body)
    Trim(From)
    Trim(Rcpt)
    If Len(From) < 1 Then
    ReportError strError & "<br>No Reply-to address (From) for this letter"
    End If
    If Len(Rcpt) < 1 Then
    ReportError strError & "<br>No recipient for this letter"
    End If
    IsValidEmail Rcpt
    IsValidEmail From
    Set objMailer = CreateObject("CDONTS.Newmail")
    objMailer.From = From
    objMailer.To = Rcpt
    objMailer.Subject = Subject
    objMailer.Body = Body
    objMailer.Send
    Set objMailer = Nothing
    End Function
    %>
    <%
    Function CheckForm()
    Dim Temp,strTmp,strForce
    strInputReq = "<br>Input required for "
    If objFM.Exists("TGrequire") = False Then
    Exit Function
    ElseIf isEmpty(objFM.Item("TGrequire")) Then
    Exit Function
    End If
    strForce = objFM.Item("TGrequire")
    Temp = Split(strForce,",",-1,1)
    For Each strTmp in Temp
    If objFM.Exists(strTmp) = False Then
    strError = strError & strInputReq & strTmp
    ElseIf Len(objFM.Item(strTmp)) < 1 Then
    strError = strError & strInputReq & strTmp
    End If
    Next
    End Function
    %>
    <%
    Function ParseForm()
    For Each Item in Request.Form
    If objFM.Exists(Item) Then
    objFM.Item(Item) = objFM.Item(Item) & "," & Request.QueryString(Item)
    Else
    objFM.Add Item,Request.Form(Item)
    End If
    Next
    For Each Item in Request.QueryString
    If objFM.Exists(Item) Then
    objFM.Item(Item) = objFM.Item(Item) & "," & Request.QueryString(Item)
    Else
    objFM.Add Item,Request.QueryString(Item)
    End If
    Next
    End Function
    %>
    <%
    Function SeqForm()
    Dim Temp,strTmp,strOrder,strOut
    If objFM.Exists("TGorder") = False Then
    Exit Function
    ElseIf isEmpty(objFM.Item("TGorder")) Then
    Exit Function
    End If
    strOrder = objFM.Item("TGorder")
    Temp = Split(strOrder,",",-1,1)
    For Each strTmp in Temp
    If objFM.Exists(strTmp) Then
    strOut = strOut & strTmp & "=" & objFM.Item(strTmp) & Chr(10)
    End If
    Next
    SeqForm = strOut
    End Function
    %>
    <%
    Function FormToString()
    Dim strOut
    strKeys = objFM.Keys
    strValues = objFM.Items
    For intCnt = 0 To objFM.Count -1
    strOut = strOut & strKeys(intCnt) & "=" & strValues(intCnt) & Chr(10)
    Next
    FormToString = strOut
    End Function
    %>
    <%
    Function ReportError(strMess)
    If Len(strMess) < 1 Then
    strMess = strError
    End If
    strErr = "The following error(s) happened: <br>" & strMess
    Response.Clear
    %>

    <!--*******ERRONEOUS SUBMISSION RESPONSE - START*******-->
    <!--ADD YOUR OWN HTML TOP SECTION STARTING HERE-->
    <h1>Error!</h1>
    <!--ADD YOUR OWN HTML TOP SECTION UP TO HERE-->

    <%'Error messages will be output here, between your html%>
    <%
    Response.Write(strErr)
    %>

    <!--ADD YOUR OWN HTML BOTTOM SECTION STARTING HERE-->
    <p>
    <b>Click on you browser's <i>Back</i> button to correct any mistakes in your input</b>
    </p>
    <!--ADD YOUR OWN HTML BOTTOM SECTION UP TO HERE-->
    <!--******ERRONEOUS SUBMISSION RESPONSE - END*******-->

    <%
    Credit
    Response.End
    End Function
    %>

    <%Function Credit%>
    <!--START OF CREDIT - DO NOT CHANGE OR REMOVE ANYTHING BELOW THIS LINE-->
    <p align=center>
    <font face="Arial,Helvetica" size=1>
    Mailer software is freeware by
    <a href="http://www.cgiware.com/" target="_top">CGIware</a> &nbsp;
    <a href="http://www.cgiware.com/" target="_top"><img src="http://www.cgiware.com/powered.gif" align="absmiddle" border="0"></a>
    </font>
    </p>
    <!--END OF CREDIT-->
    <%End Function%>

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you're using a database, just use (getdate()) as the default value for the "time" field. It will be updated whenever something is written to that field - you don't even need to write to that field, it will be updated in this case whenever a record is modified. PLay around with it, it's fun!
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #7
    New Coder
    Join Date
    Nov 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not using a database its just a form that goes through asp to my email and i just want the form to grab the time on submit and send it with the rest of the info...

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    objMailer.Body = Body & vbCrLf & vbCrLf & "Time Sent: " & Now()
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #9
    New Coder
    Join Date
    Nov 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks but where in the asp do i put that... i really dont know asp at all

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Put the part I did bold right after the part I didn't bold...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #11
    New Coder
    Join Date
    Nov 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Sorry I still don't understand where to put it... I don't know ASP at all so your gonna please have to spell it out to me... thanks

  • #12
    New Coder
    Join Date
    Nov 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok I tried it but it did not work... any other ideas?

  • #13
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not really, that's pretty basic - and it should work. I use stuff like that every day.

    Post the modified code perhaps?

    Also, you might want to look at a couple of tutorials:

    http://hotwired.lycos.com/webmonkey/programming/asp/

    http://www.w3schools.com/asp
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #14
    New Coder
    Join Date
    Nov 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well i have a bigger issue now... lol... i put that in and it didn't work... so i took it back out and left everything else the same... now the entire scipt doesn't work.. please help... here is the code

    <%@language = "VBscript"%>
    <%
    'Tom Germain's Standard Cgiware Global Variables and set-up
    'DO NOT REMOVE THIS SECTION OR NOTHING WILL WORK
    Dim strError
    Response.Buffer = True
    If ScriptEngineMajorVersion < 2 Then
    ReportError "Host system needs scripting engine upgrade to use this script"
    End If
    Set objFM = CreateObject("Scripting.Dictionary")
    If IsObject(objFM) = False Then
    ReportError "Host system lacks component(s) required by this script"
    End If
    Set objMailx = CreateObject("CDONTS.Newmail")
    If IsObject(objMailx) = False Then
    ReportError "Host system lacks component(s) required by this script"
    End If
    Set objMailx = Nothing
    %>
    <%
    'aspmailer.asp by Tom Germain, Copyright 1998-1999
    'Version 1.0
    'tg@cgiware.com
    'Visit http://www.cgiware.com for latest version, documentation, and other resources
    'This is freeware - Use at your own risk. No warranties provided.
    'Redistribution of this program, in whole or in part, is strictly
    'prohibited without the expressed written consent of the author.
    'Custom programming available on hourly fee basis.
    %>

    <%'variables you can set start here%>
    <%
    strRcpt = "webmaster@titanroofing.com" 'Put the address you want the form sent to here

    strFromVar = "E-Mail" 'If you want a reply-to email address to be taken from the form
    ' put the name of the input item here.

    strDefFrom = "formmail@titanroofing.com" 'Put a default, even fake, From address here

    strDefSubject = "Titan Roofing, Inc. Contact Form" 'Put the subject of the letter here. If an input item called
    'subject exists in the form, its value will be used instead.

    strRedirect = "Confirm.htm" 'Url to redirect to after a successful form submission. If an input item called
    'redirect exists in the form, its value will be used instead.

    %>
    <%'variables you can set end here%>

    <%
    ParseForm
    CheckForm
    If Len(strError) > 0 Then
    ReportError strError
    End If
    strOutX = SeqForm
    If Len(strOutX) < 1 Then
    strOutX = FormToString
    End If
    If Len(strOutX) < 1 Then
    ReportError "Submitted form is empty"
    End If
    strSubject = strDefSubject
    If objFM.Exists("TGsubject") Then
    strSubject = objFM.Item("TGsubject")
    End If
    strFrom = strDefFrom
    If Len(strFromVar) > 0 Then
    If objFM.Exists(strFromVar) Then strFrom = objFM.Item(strFromVar) End If
    End If
    SendMail strFrom,strRcpt,strSubject,strOutX
    If Len(strRedirect) > 0 Then
    Response.redirect(strRedirect)
    Response.End
    End If
    If objFM.Exists("TGredirect") = True Then
    If Len(objFM.Item("TGredirect")) > 0 Then
    Response.redirect(objFM.Item("TGredirect"))
    Response.End
    End If
    End If
    %>

    <!--*******SUCCESSFUL SUBMISSION RESPONSE - START*******-->
    <!--ADD YOUR OWN HTML TOP SECTION STARTING HERE-->
    <h1>Form Sent!</h1>
    Your request has been received and will be processed shortly.
    <!--ADD YOUR OWN HTML TOP SECTION UP TO HERE-->
    <!--*******SUCCESSFUL SUBMISSION RESPONSE - END********-->

    <%
    Credit
    Response.End
    %>
    <%
    Function IsValidEmail(Email)
    Dim Temp,Temp2
    strNotValid = "<br>Email address not valid"
    strTooLong = "<br>Email address too long"
    If Len(Email) > 100 Then
    ReportError strTooLong
    End If
    Email = LCase(Email)
    Temp = Split(Email,"@",2,1)
    If UBound(Temp) < 1 Then
    ReportError strNotValid
    End If
    Temp2 = Split(Temp(1),".",-1,1)
    If UBound(Temp2) < 1 Then
    ReportError strNotValid
    End If
    End Function
    %>
    <%
    Function SendMail(From,Rcpt,Subject,Body)
    Trim(From)
    Trim(Rcpt)
    If Len(From) < 1 Then
    ReportError strError & "<br>No Reply-to address (From) for this letter"
    End If
    If Len(Rcpt) < 1 Then
    ReportError strError & "<br>No recipient for this letter"
    End If
    IsValidEmail Rcpt
    IsValidEmail From
    Set objMailer = CreateObject("CDONTS.Newmail")
    objMailer.From = From
    objMailer.To = Rcpt
    objMailer.Subject = Subject
    objMailer.Body = Body
    objMailer.Send
    Set objMailer = Nothing
    End Function
    %>
    <%
    Function CheckForm()
    Dim Temp,strTmp,strForce
    strInputReq = "<br>Input required for "
    If objFM.Exists("TGrequire") = False Then
    Exit Function
    ElseIf isEmpty(objFM.Item("TGrequire")) Then
    Exit Function
    End If
    strForce = objFM.Item("TGrequire")
    Temp = Split(strForce,",",-1,1)
    For Each strTmp in Temp
    If objFM.Exists(strTmp) = False Then
    strError = strError & strInputReq & strTmp
    ElseIf Len(objFM.Item(strTmp)) < 1 Then
    strError = strError & strInputReq & strTmp
    End If
    Next
    End Function
    %>
    <%
    Function ParseForm()
    For Each Item in Request.Form
    If objFM.Exists(Item) Then
    objFM.Item(Item) = objFM.Item(Item) & "," & Request.QueryString(Item)
    Else
    objFM.Add Item,Request.Form(Item)
    End If
    Next
    For Each Item in Request.QueryString
    If objFM.Exists(Item) Then
    objFM.Item(Item) = objFM.Item(Item) & "," & Request.QueryString(Item)
    Else
    objFM.Add Item,Request.QueryString(Item)
    End If
    Next
    End Function
    %>
    <%
    Function SeqForm()
    Dim Temp,strTmp,strOrder,strOut
    If objFM.Exists("TGorder") = False Then
    Exit Function
    ElseIf isEmpty(objFM.Item("TGorder")) Then
    Exit Function
    End If
    strOrder = objFM.Item("TGorder")
    Temp = Split(strOrder,",",-1,1)
    For Each strTmp in Temp
    If objFM.Exists(strTmp) Then
    strOut = strOut & strTmp & "=" & objFM.Item(strTmp) & Chr(10)
    End If
    Next
    SeqForm = strOut
    End Function
    %>
    <%
    Function FormToString()
    Dim strOut
    strKeys = objFM.Keys
    strValues = objFM.Items
    For intCnt = 0 To objFM.Count -1
    strOut = strOut & strKeys(intCnt) & "=" & strValues(intCnt) & Chr(10)
    Next
    FormToString = strOut
    End Function
    %>
    <%
    Function ReportError(strMess)
    If Len(strMess) < 1 Then
    strMess = strError
    End If
    strErr = "The following error(s) happened: <br>" & strMess
    Response.Clear
    %>

    <!--*******ERRONEOUS SUBMISSION RESPONSE - START*******-->
    <!--ADD YOUR OWN HTML TOP SECTION STARTING HERE-->
    <h1>Error!</h1>
    <!--ADD YOUR OWN HTML TOP SECTION UP TO HERE-->

    <%'Error messages will be output here, between your html%>
    <%
    Response.Write(strErr)
    %>

    <!--ADD YOUR OWN HTML BOTTOM SECTION STARTING HERE-->
    <p>
    <b>Click on you browser's <i>Back</i> button to correct any mistakes in your input</b>
    </p>
    <!--ADD YOUR OWN HTML BOTTOM SECTION UP TO HERE-->
    <!--******ERRONEOUS SUBMISSION RESPONSE - END*******-->

    <%
    Credit
    Response.End
    End Function
    %>

    <%Function Credit%>
    <!--START OF CREDIT - DO NOT CHANGE OR REMOVE ANYTHING BELOW THIS LINE-->
    <p align=center>
    <font face="Arial,Helvetica" size=1>
    Mailer software is freeware by
    <a href="http://www.cgiware.com/" target="_top">CGIware</a> &nbsp;
    <a href="http://www.cgiware.com/" target="_top"><img src="http://www.cgiware.com/powered.gif" align="absmiddle" border="0"></a>
    </font>
    </p>
    <!--END OF CREDIT-->
    <%End Function%>

  • #15
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, well first of all, that script is WAY too complicated for a simple email submission form. Check this out instead:

    http://www.solidscripts.com/email.txt

    I think the code above is a little easier to understand, in order to add a date stamp you could simply modify this Subroutine (same code):

    Code:
    <% Sub SendEmail() ''''''''''''''''''''''''''''''
    Set objMail = Server.CreateObject("CDONTS.NewMail")
    objMail.To = "support@solidscripts.com"
    objMail.From = """" &  Name & """" & " <" & Email & ">"
    objMail.cc = ""
    objMail.bcc = ""
    objMail.Subject = Subject
    objMail.Body = Message  & vbCrLf & vbCrLf & "Time Sent: " & Now()
    objMail.Send
    Set objMail = Nothing
    ' We'll insert some HTML below to make this a Thank You page. %>
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
    <head>
         <title>Thank you!</title>
         <meta http-equiv="refresh" content="4;URL=email.asp">
    </head>
    
    <body>
    
    <h1>Thank you!</h1>
    
    <p>Thank you for contacting us. We will get back to you as soon as possible.</p>
    
    </body>
    </html>
    <%
    End Sub ''''''''''''''''''''''''''''''''''''''''' %>
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •