Question

Passing automatic Values

Asked by: roduno

I am trying to pass 2 automatic values from my form to my post page which sends me the emailed information.  The 2 values are a timestamp and an automatic number assigned as the Primary Key.  The problem is that the values do not show up in the email.  Everything else does.

Form code:
<input type="hidden" name="time_stamp" value="<%= request.form("time_stamp") %>">
                        <input type="hidden" name="Number_1" value="<%= request.form("Number_1") %>">

Post page code:

Dim time_stampname,time_stamp,Number_1name,Number_1
time_stampname = "Time"
time_stamp = Request.Form("time_stamp")
Number_1name = "Form ID"
Number_1 = Request.Form("Number_1")
Dim mailmsg
Set mailmsg = Server.CreateObject("CDONTS.NewMail")
mailmsg.To = "myemail"
mailmsg.From = "server"
mailmsg.Subject = "Form Submission"
mailmsg.Body = time_stampname & vbcrlf&_
time_stamp & vbcrlf&_
Number_1name & vbcrlf&_
Number_1
mailmsg.Host = "mail server"
mailmsg.Send
Set mailmsg = Nothing

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-07-11 at 13:30:51ID21054888
Topic

Active Server Pages (ASP)

Participating Experts
2
Points
500
Comments
35

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Request.Form
    Hi- I'm using Request.Form(element)[(index).count]! Most of the time I have no problem using a command such as request.form("orderName") However, I have a specific example where the element isn't defined by me. The element (or the name of the form to use) is...
  2. Request.form
    Does anyone know a quick and simple way of putting everything in Request.form into an array? I'm looking at passing it as a string, then parsing it into an array. I wrote a component that I pass Request.Form into, which I pass as an object, however, our Network structure wo...
  3. Request.Form()
    Hi, Suppose we poste a value in a form of page1. We then get the value with Request.Form() in page2. My question is that can we get the value by Request.Form() in page3 ?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: pkaledaPosted on 2004-07-11 at 13:56:03ID: 11524912

You can try this:

mailmsg.Body = time_stampname & vbcrlf
mailmsg.Body = mailmsg.Body & time_stamp & vbcrlf
mailmsg.Body = mailmsg.Body & Number_1name & vbcrlf
mailmsg.Body = mailmsg.Body & Number_1

 

by: rodunoPosted on 2004-07-11 at 14:21:02ID: 11525029

No luck, the email still has no values:

This is a multi-part message in MIME format.

--CS_MAIL_Part_Boundary_10301998
Content-Type: text/plain
Content-Transfer-Encoding: 7Bit

Time

Form ID

--CS_MAIL_Part_Boundary_10301998--

 

by: pkaledaPosted on 2004-07-11 at 14:28:55ID: 11525052

Dim time_stampname,time_stamp,Number_1name,Number_1
time_stampname = "Time"
time_stamp = Request.Form("time_stamp")
Number_1name = "Form ID"
Number_1 = Request.Form("Number_1")
Dim mailmsg
Set mailmsg = Server.CreateObject("CDONTS.NewMail")
mailmsg.To = "myemail"
mailmsg.From = "server"
mailmsg.Subject = "Form Submission"
MyBody = time_stampname & vbcrlf
MyBody = MyBody & time_stamp & vbcrlf
MyBody = MyBody & Number_1name & vbcrlf
MyBody = MyBody & Number_1
mailmsg.Body= MyBody
mailmsg.Host = "mail server"
mailmsg.Send
Set mailmsg = Nothing

 

by: fritz_the_blankPosted on 2004-07-11 at 14:37:00ID: 11525081

May I see the form please?

FtB

 

by: fritz_the_blankPosted on 2004-07-11 at 14:39:27ID: 11525092

Actually, I think that the problem is here:

<input type="hidden" name="time_stamp" value="<%= request.form("time_stamp") %>">
                    <input type="hidden" name="Number_1" value="<%= request.form("Number_1") %>">

My guess is that you have no values being passed for time_stamp or for Number_1....

How is the form grabbing these values?

to prove my point, try this at the top of the mail page:

<%
for each objField in Request.Form
  response.write(objField & ": " & request.Form(objField) & "<br>")
next
%>

If you have no values in the request objects, they will show up empty in the mail!

FtB

 

by: rodunoPosted on 2004-07-11 at 14:47:26ID: 11525130

The form needs to grab the values from the database where they are populated automatically.  Nothing is entered into the form for these two values.  I tried the test and I did not get anything so the problem may well be with the input type hidden syntax.

 

by: fritz_the_blankPosted on 2004-07-11 at 14:52:13ID: 11525140

<input type="hidden" name="time_stamp" value="<%= request.form("time_stamp") %>">
                    <input type="hidden" name="Number_1" value="<%= request.form("Number_1") %>">


should be:

<input type="hidden" name="time_stamp" value="<%= objRS("time_stamp") %>">
                    <input type="hidden" name="Number_1" value="<%= objRS("Number_1") %>">

just replace objRS with the name of the recordset that is supposed to populate the form.

Fritz the Blank

 

by: rodunoPosted on 2004-07-11 at 14:54:26ID: 11525151

I tried the "Mybody=" from Pkaleda but unfortunately still no results.  Same result as before.

 

by: rodunoPosted on 2004-07-11 at 15:03:47ID: 11525195

I must be misunderstanding something.  I did the following:

<input type="hidden" name="time_stamp" value="<%= time_stamp("time_stamp") %>">
                        <input type="hidden" name="Number_1" value="<%= Number_1("Number_1") %>">

and received the following error:

Error Type:
Sun ONE ASP VBScript runtime (0x800A000D)
Type mismatch
/service.asp, line 82

I'm doing this in the form page...is that correct and not in the posting page.

 

by: pkaledaPosted on 2004-07-11 at 15:06:02ID: 11525205

When you are pulling them from a database during the query you should do something like:

Set rs = conn.execute(sql)

then you would put:

<input type="hidden" name="time_stamp" value="<%= rs.fields("time_stamp") %>">
                    <input type="hidden" name="Number_1" value="<%= rs.fields("Number_1") %>">

Whatever you call your record set is what RS is.

 

by: fritz_the_blankPosted on 2004-07-11 at 15:06:03ID: 11525207

Oh no! That's not right.

Please post all of the code for the form page, and I'll see if I can sort this out with you.

FtB

 

by: fritz_the_blankPosted on 2004-07-11 at 15:07:43ID: 11525216

@pkaleda--

Beat you by a minute with the same comment!!!

FtB

 

by: pkaledaPosted on 2004-07-11 at 15:13:53ID: 11525232

Yeah.  Good catch on writing the form fields out.  

;-)

 

by: rodunoPosted on 2004-07-11 at 15:16:11ID: 11525239

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
DIM objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DSN=mydb"
objConn.Open
mySQL = "SELECT DISTINCT state_id FROM state ORDER BY state_id"
DIM objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, objConn
%>

<html>
<head>
<title>mytitle</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="black"><font color="white">
                  <form method=Post action=getcus.asp>
                        <b><font face="Times New Roman,Georgia,Times">*My text!</font></b><br>
                        <br>
                        Name<br>
                        <input type="text" name="t1" size="20"><br>
                        Title<br>
                        <input type="text" name="t2" size="20"><br>
                        Company<br>
                        <input type="text" name="t3" size="20"><br>
                        City<br>
                        <input type="text" name="t4" size="20"><br>
                        State<br>
                        <select name="state_name">
                              <%Do While Not objRS.EOF%>
                              <option value='<%=objRS("state_id")%>'><%=objRS("state_id")%></option><%objRS.MoveNext
Loop
objRS.close
Set objRS = NOTHING
objConn.Close
Set objConn = Nothing
%>
                        </select><br>
                        Country<br>
                        USA<input type="checkbox" name="Country" value="USA"> OTHER<input type="checkbox" name="Country" value="OTHER"> <input type="text" name="t5" size="20"><br>
                        Email<br>
                        <input type="text" name="t6" size="20"><br>
                        <br>
                        Describe <br>
                        <textarea rows="4" name="st" cols="50"></textarea><br>
                        <br>
                        What do you want ?<br>
                        select1<input type="checkbox" name="site" value="select1"><br>
                        select2<input type="checkbox" name="site" value="select2"><br>
                        select3<input type="checkbox" name="site" value="select3"><br>
                        <br>
                        What Services?<br>
                        select1<input type="checkbox" name="service" value="select1"><br>
                        select2<input type="checkbox" name="service" value="select2"><br>
                        select3<input type="checkbox" name="service" value="select3"><br>
                        select4<input type="checkbox" name="service" value="select4"><br>
                        <br>
                        Current location &nbsp;&nbsp; <input type="text" name="t7" size="20"><br>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;www.domain.com<br>
                        <br>
                        Question<br>
                        <textarea rows="4" name="t8" cols="50"></textarea><br>
                        <br>
                        <br>
                        Question2.<br>
                        <textarea rows="4" name="t9" cols="50"></textarea><br>
                        <br>
                        <br>
                        Context?<br>
                        Yes<input type="checkbox" name="context" value="Yes"><br>
                        No<input type="checkbox" name="context" value="No"><br>
                        <br>
                        budget?<br>
                        <input type="text" name="t10" size="20"><br>
                        <br>
                        Questions, Comments?<br>
                        <textarea rows="4" name="t11" cols="50"></textarea><br>
                        <br>
                        <input type="hidden" name="time_stamp" value="<%= objRS("time_stamp") %>">
                        <input type="hidden" name="Number_1" value="<%= objRS("Number_1") %>">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="submit">
                  </form>

</body>
</html>

 

by: fritz_the_blankPosted on 2004-07-11 at 15:22:01ID: 11525265

Okay, so there is nothing populating these:

 <input type="hidden" name="time_stamp" value="<%= objRS("time_stamp") %>">
  <input type="hidden" name="Number_1" value="<%= objRS("Number_1") %>">

If you want a time stamp, then change the first line to this:

<input type="hidden" name="time_stamp" value="<%= Now()%>">

Please tell me a little more about the value that should be in the Number_1 field.

FtB

 

by: pkaledaPosted on 2004-07-11 at 15:22:49ID: 11525271

You are writing the objRS("time_stamp") and Number_1 after you have closed and ste objRS to nothing.  I do not see where yo have a query pulling the time_stamp and Number_1.  You need to pull them before you can write them.

 

by: pkaledaPosted on 2004-07-11 at 15:23:39ID: 11525275

Beat me by a few seconds on that one FTB.

;-)

 

by: rodunoPosted on 2004-07-11 at 15:27:54ID: 11525289

The Number_1 field is an automatic auto increment integer that populates the database for each record that is submitted and acts as the Primary key.

 

by: rodunoPosted on 2004-07-11 at 15:29:39ID: 11525301

The numbers are not created until the form is processed so wouldn't it be incorrect to have a query for numbers that don't yet exist?

 

by: pkaledaPosted on 2004-07-11 at 15:31:38ID: 11525309

Well it sounds like you need to process the form, then move to another page.  Then query the form for time_stamp and Number_1 and then move to the mail page.   You cannot get the number before the form is processed either.

 

by: fritz_the_blankPosted on 2004-07-11 at 15:32:42ID: 11525313

Okay, so you don't need to add that--the database will take care of it. So:

On your form do this:

<input type="hidden" name="time_stamp" value="<%= objRS("time_stamp") %>">
 
but don't add anything for the number.

 

by: fritz_the_blankPosted on 2004-07-11 at 15:34:25ID: 11525318

Then on the mail page, try this:

'perform your update using a recordset object so that you can get the auto increment ID
Dim time_stampname,time_stamp,Number_1name,Number_1
time_stampname = "Time"
time_stamp = Request.Form("time_stamp")
Number_1name = "Form ID"
Number_1 = objRS("Number_1")
Dim mailmsg
Set mailmsg = Server.CreateObject("CDONTS.NewMail")
mailmsg.To = "myemail"
mailmsg.From = "server"
mailmsg.Subject = "Form Submission"
mailmsg.Body = time_stampname & vbcrlf&_
time_stamp & vbcrlf&_
Number_1name & vbcrlf&_
Number_1
mailmsg.Host = "mail server"
mailmsg.Send
Set mailmsg = Nothing

 

by: pkaledaPosted on 2004-07-11 at 15:39:20ID: 11525339

You can perform another query after you have inputted it.  I think FTB that he wants to mail the Number_1 to himself as evidenced by:

Number_1name & vbcrlf&_
Number_1


So I would do this:

'perform your update using a recordset object so that you can get the auto increment ID

' Open a query to pull the number_1 and Time_stamp from the database.  Make it objRS

Dim time_stampname,time_stamp,Number_1name,Number_1
time_stampname = "Time"
time_stamp = objRS("time_stamp")
Number_1name = "Form ID"
Number_1 = objRS("Number_1")
Dim mailmsg
Set mailmsg = Server.CreateObject("CDONTS.NewMail")
mailmsg.To = "myemail"
mailmsg.From = "server"
mailmsg.Subject = "Form Submission"
mailmsg.Body = time_stampname & vbcrlf&_
time_stamp & vbcrlf&_
Number_1name & vbcrlf&_
Number_1
mailmsg.Host = "mail server"
mailmsg.Send
Set mailmsg = Nothing

 

by: fritz_the_blankPosted on 2004-07-11 at 15:41:21ID: 11525348

@pkaleda:

Great minds think alike....

FtB

 

by: pkaledaPosted on 2004-07-11 at 15:42:46ID: 11525355

Coming from you that is a GREAT COMPLIMENT.   You have about 14 million more points than me.  LOL

 

by: fritz_the_blankPosted on 2004-07-11 at 15:45:15ID: 11525364

When I wrote this:

'perform your update using a recordset object so that you can get the auto increment ID

in my post above, I had in mind something like:

strSQL = "SELECT * FROM tblYourTable WHERE 1=0"
objRS.Open strSQL, objConn,3,3
objRS.AddNew()
  objRS("time_stamp") = Request.Form("time_stamp")
  objRS("state_ID") = Request.Form("state_name")
objRS.Update()

Number_1 = objRS("Number_1")


 

by: pkaledaPosted on 2004-07-11 at 15:48:40ID: 11525379

In addition instead of on the previous page having:
 <input type="hidden" name="time_stamp" value="<%= Now()%>">  
He may have the Time_stamp as a datetime field in his database that he writes when he enters the data.  I would do that so that I can see when they committed it to the table.  

That way he can write the time_stamp from the database.

 

by: fritz_the_blankPosted on 2004-07-11 at 15:51:23ID: 11525390

I am not sure what is meant there...a time stamp from when the record was added or from something else.

If I understand this correctly, the only thing that needs to be populated by the database on the form is the state list, but I could be wrong about that.

FtB

 

by: rodunoPosted on 2004-07-12 at 20:41:08ID: 11535817

Whenever I add this : <input type="hidden" name="time_stamp" value="<%= objRS("time_stamp") %>">
to the form I get the following error:

Error Type:
Sun ONE ASP VBScript runtime (0x800A01A8)
Object required: 'objRS'
/service.asp, line 82


 

by: rodunoPosted on 2004-07-12 at 20:50:20ID: 11535864

I am also getting errors when I input the query in the mail page.....  see mail page code below in working state.  Please let me know where I should input the query:

Response.Buffer = true
dim objConn,objrst
set objConn = Server.CreateObject("ADODB.Connection")
set objrst = Server.CreateObject("ADODB.RecordSet")
objConn.ConnectionString = "DSN=mydb"
objConn.Open
sqltext = "SELECT * FROM service"
objrst.Open sqltext,objConn,3,3
objrst.AddNew
objrst("t1") = Request.Form("t1")
objrst("t2") = Request.Form("t2")
objrst("t3") = Request.Form("t3")
objrst("t4") = Request.Form("t4")
objrst("state_name") = Request.Form("state_name")
objrst("country") = Request.Form("country")
objrst("t5") = Request.Form("t5")
objrst("t6") = Request.Form("t6")
objrst("st") = Request.Form("st")
objrst("site") = Request.Form("site")
objrst("stuff1") = Request.Form("stuff1")
objrst("t7") = Request.Form("t7")
objrst("t8") = Request.Form("t8")
objrst("t9") = Request.Form("t9")
objrst("stuff2") = Request.Form("stuff2")
objrst("t10") = Request.Form("t10")
objrst("t11") = Request.Form("t11")
objrst.update
objrst.Close
Set objrst= Nothing
objConn.close
Set objConn= Nothing
%>

<%Dim t1name,t1,t2name,t2,t3name,t3,t4name,t4
t1name = "Name"
t1 = Request.Form("t1")
t2name = "Title"
t2 = Request.Form("t2")
t3name = "Company"
t3 = Request.Form("t3")
t4name = "City"
t4 = Request.Form("t4")
Dim state_namename,state_name,Countryname,Country
state_namename = "State"
state_name = Request.Form("state_name")
Countryname = "Country"
Country = Request.Form("Country")
Dim t5name,t5,t6name,t6
t5name = "Other Country"
t5 = Request.Form("t5")
t6name = "Email"
t6 = Request.Form("t6")
Dim stname,st
stname = "Statement:"
st = Request.Form("st")
Dim sitename,site
sitename = "Question?"
site = Request.Form("site")
Dim servicename,service
servicename = "Question?"
service = Request.Form("service")
Dim t7name,t7,t8name,t8,t9name,t9
t7name = "Statement"
t7 = Request.Form("t7")
t8name = "Question?"
t8 = Request.Form("t8")
t9 = "Statement"
t9 = Request.Form("t9")
Dim contextname,context
contextname = "Question?"
context = Request.Form("context")
Dim t10name,t10,t11name,t11
t10name = "Question?"
t10 = Request.Form("t10")
t11name = "Question?"
t11 = Request.Form("t11")
Dim time_stampname,time_stamp,Number_1name,Number_1
time_stampname = "Time"
time_stamp = Request.Form("time_stamp")
Dim mailmsg
Set mailmsg = Server.CreateObject("CDONTS.NewMail")
mailmsg.To = "me@mydomain"
mailmsg.From = "service@mydomain.com"
mailmsg.Subject = "Form Submission"
mailmsg.Body = t1name & vbcrlf&_
t1 & vbcrlf&_
t2name & vbcrlf&_
t2 & vbcrlf&_
t3name & vbcrlf&_
t3 & vbcrlf&_
t4name & vbcrlf&_
t4 & vbcrlf&_
state_namename & vbcrlf&_
state_name & vbcrlf&_
Countryname & vbcrlf&_
Country & vbcrlf&_
t5name & vbcrlf&_
t5 & vbcrlf&_
t6name & vbcrlf&_
t6 & vbcrlf&_
stname & vbcrlf&_
st & vbcrlf&_
sitename & vbcrlf&_
site & vbcrlf&_
servicename & vbcrlf&_
service & vbcrlf&_
t7name & vbcrlf&_
t7 & vbcrlf&_
t8name & vbcrlf&_
t8 & vbcrlf&_
t9name & vbcrlf&_
t9 & vbcrlf&_
contextname & vbcrlf&_
context & vbcrlf&_
t10name & vbcrlf&_
t10 & vbcrlf&_
t11name & vbcrlf&_
t11 & vbcrlf&_
time_stampname & vbcrlf&_
time_stamp & vbcrlf&_
Number_1name & vbcrlf&_
Number_1
mailmsg.Host = "mail.mydomain.com"
mailmsg.Send
Set mailmsg = Nothing
%></font></b></font></p>

 

by: pkaledaPosted on 2004-07-13 at 05:01:20ID: 11538064

On the form page you have closed ObjConn and ObjRS and set them to nothing much earlier on the page.  So once you get to the line where you input the time stamp into the form, it has nothing to enter.  I also see on the form page that the query where you set objRS it looks like the query never pulls a time_stamp into the objRS anyway.  FtB earlier said that you can change that line on the form to read this:

<input type="hidden" name="time_stamp" value="<%= Now()%>">

That will set the value to the time that the form is displayed to the user to be filled out.  

Conversly, you can omit it from the form alltogether and put it on the processing page by changing this " time_stamp = Request.Form("time_stamp") " to " time_stamp = now() ".  This will then set the time_stamp to the time that you are processing the input.

On the service page I would do this:

<%Response.Buffer = true
dim objConn,objrst
set objConn = Server.CreateObject("ADODB.Connection")
set objrst = Server.CreateObject("ADODB.RecordSet")
objConn.ConnectionString = "DSN=mydb"
objConn.Open
sqltext = "Insert into service (t1, t2, t3, t4, state_name, country, t5, t6, st, site, stuff1, t7, t8, t9, stuff2, t10, t11) values ('"&Request.Form("t1")&"', ''"&Request.Form("t2")&"','"&Request.Form("t3")&"','"&Request.Form("t4")&"','"&Request.Form("state_name")&"','"&Request.Form("country")&"','"&Request.Form("t5")&"','"&Request.Form("t6")&"','"&Request.Form("st")&"','"&Request.Form("site")&"','"&Request.Form("stuff1")&"','"&Request.Form("t7")&"','"&Request.Form("t8")&"','"&Request.Form("t9")&"','"&Request.Form("stuff2")&"','"&Request.Form("t10")&"','"&Request.Form("t11")&"')"
objConn.execute(sqltext)
objConn.close
Set objConn= Nothing
%>

PK

 

by: rodunoPosted on 2004-07-13 at 20:38:24ID: 11545741

OK, so I have the time_stamp working, thanks!  I am still a bit confused on how to get the auto increment number.  I tried inputting Number_1 = objRS("Number_1")
into the service page but I get an error:  Error Type:
Sun ONE ASP VBScript runtime (0x800A000D)
Type mismatch
/getcus.asp, line 125

I don't quite understand the query that FTB wrote up top:
strSQL = "SELECT * FROM tblYourTable WHERE 1=0"
objRS.Open strSQL, objConn,3,3
objRS.AddNew()
  objRS("time_stamp") = Request.Form("time_stamp")
  objRS("state_ID") = Request.Form("state_name")
objRS.Update()

Number_1 = objRS("Number_1")

Is this query supposed to go in the form page or the service page?  

 

by: pkaledaPosted on 2004-07-14 at 05:13:03ID: 11548051

I am going to assume that your database is setting the number_1  auto increment value automatically.  What I would do is just after the service page has input the data into the database, I would then query the database based on the same form values for what the Number_1 is.

Just after the input query, I would runa a query on some specific data from the form.  You do not specify what t1, t2 t3 or t4 are above.  Assuming they are like a name or unique id, you could query on them.  

This is an example:

<%
dim objConn,objrst
set objConn = Server.CreateObject("ADODB.Connection")
set objrst = Server.CreateObject("ADODB.RecordSet")
objConn.ConnectionString = "DSN=mydb"
objConn.Open
sqltext = "Select top 1 * from service where t1 = '"&request.form("t1")&"' and t2 = '"&request.form("t2")&"' and t3 = '"&request.form("t3")&"' order by id desc"
set objRS = objConn.execute(sqltext)
If not objRS.eof then
while not objRS.eof
number_1 = objRS("number_1")
wend
end if
objConn.close
Set objConn= Nothing
set objRS = Nothing
%>

What you are doing here is returning the last record inputed that match teh current t1, t2 and t3 values and setting number_1 to the value for number_1 in teh database.

PK




 

by: fritz_the_blankPosted on 2004-07-29 at 06:25:40ID: 11666067

After all of this, a B? So much for the old saying "A for effort!"

FtB

 

by: pkaledaPosted on 2004-07-29 at 07:52:57ID: 11667047

LOL FtB.  I know what you mean.  I have never given a  B.  If someone is taking time to help, they get an A in my book.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...