Click to See Complete Forum and Search --> : <%=(Session.SessionID)%>
toastg
09-22-2003, 09:40 AM
I am trying to find out how to keep a session alive throughout a users vist... My site writes form data to an access database table - I have a hidden field in my form page writing <%=(Session.SessionID)%> to the database. Do i even need to capture this info? I have the users data being written to one line of the access table - I want to pull info from that line if the user wants to submit another form... how do I pull that info back when the user is going from page to page.... Is it something that can be set from the global.asa? Any help woulp be greatly appriciated....
Ribeyed
09-23-2003, 05:11 AM
Hi,
i got a slight idea what you are trying to do, but your post is vague and not very helpful, you should read the announcement by our moderator.
http://forums.webdeveloper.com/announcement.php?s=&forumid=9
toastg
09-23-2003, 10:03 AM
I have a website that is connected to an access database - there are forms that are linked from one page to another. I need the data that is written on the previouse page to appear on the next page. Then any info submitted ont that page added to the same line and table of the access database.
Ribeyed
09-23-2003, 10:25 AM
hi,
ok, you send the form to the next page or the same page(recommended) using either of the 2 methods; get and post. The method used will determine the next page/same page code.
Ok the form posts the form elements; textboxes, checkboxes, hidden fields, radio buttons, list/menus etc. to the page specified in the form tag. Now to retrieve these you used the ASP command REQUEST and the collections of that object.
example form:
<form action="samepage.asp" method="post" name="form1"
<input name="field" type="text" class="textbox" value="value">
</form>
so the code for retrieving the values whould be like this:
thevalue = request.form("field")
to insert that value to a database you would do this:
DBConn.Execute "INSERT INTO tblTable (Databasefield) VALUES ("&field&")"
This code will work providing the database field is set to char/text but not numeric/int.
toastg
09-23-2003, 10:47 AM
much thanks for your quick reply - i will try it - how about if the user finishes submitting the form and wants to submit another one - I would have a button at the bottom of the confermation page to do another request - it would take them back to the begining but would thier info be in the text boxes they filled out before? just so they dont have to re-enter the same info?
Ribeyed
09-23-2003, 11:09 AM
hi,
alot of new ASP programmer have a notion that a form has to be posted to another page. This causes problems with form validation using server-side scripting and the retaining of the values entered when displaying the form again. I would allways recommend posting your form not to another page but to the same page. Using if statements you can block your code to only run the correct code when required.
example:
start your code on the first form page like so:
thesubmit = request.form("Submit")
Here you are requesting the value of the submit button. Now if the user has first requested the page then the value will be blank. If the user has submitted the form the this value will not be blank. You can then do the following.
if thesubmit <> "" then
'validate the form or process the form.
'so you would do your request code here like so:
textbox1 = request.form("textbox1")
textbox2 = request.form("textbox2")
'you can now valuate them, make sure they are not empty
if textbox1 = "" then
error1 = "yes"
end if
if textbox2 = "" then
error2 = "yes"
end if
'now if an error has occur you still want to display the form.
'you will need to code this yourself.
else
'display the form here.
end if
Ok thats the basic way. You want to alter your form elements to reflect this code.
<form action="samepage.asp" method="post" name="form1"
<input name="textbox1" type="text" class="textbox" value="<%=textbox1%>">
</form>
Doing this will retain the values of the form elements in your form.
Hope this helps.
[/code]
toastg
09-23-2003, 02:32 PM
thank you for all your help - i'll give it a try......