Replies Back to Article

Passing Form Values to a second page when using MM Insert or Edit

Possing the parameters
February 25, 2001 by George Petrov
Mike, I don't think MM made a mistake. They just passed the parameters from the form page to the next page. Usually you don't want to pass the form fields - you store them in the db or do some actions with them.
RE: Possing the parameters
February 25, 2001 by Mike T

You are 100% right.  That is what really confused me.  I originally was planning on creating an extension that Added some code if you wanted to pass the values.  However,  everytime I added code,  it got changed somewhere else,  so I took a closer look at the stock code,   and saw the MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
that is part of the Stock code.   What is that code in the MM code for unless they were trying to add the values back into the redirect?   Then,  the second question is:  If that code is there,  why arent the values available on the redirect page?

Only answer I could come up with is,   request.querystring pulls values from a GET method.   The Insert and Update both use POST,  and you have to use the Request.Form to retrieve the values in a POST.

I am still a little confused on why the stock code is set up like it is,  but,  if anyone wants to pass values,   this will show them how to do it if they want.

Thanks
Mike T

RE: RE: Possing the parameters
February 25, 2001 by George Petrov

Well I will explain a bit. Lets take the follwoin scenario:

You have articles. On the list with all the articles you have, per article, link to the detail page. The link is something like showDetail.asp?ArtId=10

On the detail page you have a Update Record behavior. When you submit the form, it gets updated in the db, to resubmit you want:

  • redirect to "thank you" page, where you mind what to show the updated article again, so the ArtId parameter is still needed
  • redirect to "Send Notification Mail" page where you want to send a notification mail to somebody that the article has been updated. Then you also need the ArtId on the next page.

Those are just some of the examples I can think of.

Anyway - your tutorial is great! Keep up the good work!

Passing parameters
September 21, 2001 by Frédéric Frédéric

I still don't get it:

# when using the ultradev system to insert or update a record it uses a post method.  So we should request using request.form... in the reply-page.

# if we do this:  it doesn't work.

# but if we change the code in the initial page from "request.querystring" to "request.form" (as said in the tutorial) AND use "request.querysting" on the reply-page it works.

# Seems completely UNLOGIG to me.  If someone could explain it would be great!

RE: Passing parameters
September 21, 2001 by Mike T

Nicholas,

Here is the overall view of what is happening...

Page1 -   form POSTS to Page1  (posts back to itself) The insert or update behavior adds a hidden field to your form called MM_insert  OR MM_update and sets it to TRUE.

Page1 -  The MM insert or update sees the MM_insert OR MM_update field and performs the Insert or Update.  That is what this "If (CStr(Request("MM_insert")) <> "") Then" piece of code is.

It then REDIRECTS to page 2.  So,  form values ARE NOT available through a redirect,  unless you manually attach those form values to the redirect URL as part of the URL string.

MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.Form Is telling it to take your redirect URL  (page2.asp)   and add ALL of the form values to it. 

Page2.   You got to this page via a REDIRECT,  so,   Request.Form is NOT VALID.  However,  all of your form values were passed as part of the URL string,  so,  now on this page,  you need to use Request.QueryString  to get the values.

 

Hope this helps

Mike T

RE: RE: Passing parameters
September 22, 2001 by Frédéric Frédéric

GOT IT!

I didn't know page-1 posted first to itself.  That explains a lot.

Thanks again.

Nicholas

code problem
November 30, 2001 by Jeff Davis

Thanks for the tutorial!  I think this will really help, but I am having a problem.  This is the code I have in my page with the changes.  The code is a little different form yours, probably javascript vs. vbscript?  I am using Ultra Dev 4.  Anyway, I can't seem to get the form values to pass to the redirect page.  Any thoughts?  Do I need to change another selection of code to Request.Form that I am missing?

Another Note: The last Request.Form piece of code below is no longer red in my script?  Did I screw something up.

Thanks again,

Jeff

 

// append the query string to the redirect URL
  if (MM_editRedirectUrl && Request.Form && Request.Form.length > 0) {
    MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.Form;
  }
}

Great Tutorial
January 10, 2002 by Kelly Brady

Its funny by when I first realized this issue I started creating Stored Procedures for all my inserts and updates, for the reason of being able to use the data on the second page to either display the results back to a user so they can print the information out or to include it in a CDONTS script to send an email. I love stored procedures for all they are worth but if you working in environments where the database tables are changing then it’s kind of a pain to have to recreate the stored procedure and the Ultradev code. Thanks again I think I may use this more often

This might help too...
January 18, 2002 by ed hidden

Using this simple fix I found on Macromedia.com, you might be able to do something similar (It's a one word fix to pass the Query String info to the next page.)

http://www.macromedia.com/support/ultradev/ts/documents/sb_qs_redirect.htm

Ed

 

Tutorial
March 1, 2002 by Bogdan Zagan

Very usefull, Thanx. There are other methods modifing the UD code, but this is the most elegant one !

Thanx again

Pass Form Values to second page when using Macromedia's Insert Record or Update Record.
June 27, 2002 by Jason Chandler

I have another method which i think is a bit easier, and only if your server runs ASP 3

Simply find this code

response.redirect  ("MM_editRedirectUrl ")

and change it to

Server.Transfer  ("MM_editRedirectUrl ")

this will also make your form variables available to you on the second page using, Request.Form(myform")

Try it out

Error on following page
July 29, 2002 by Brian Milner

Ok, here's the problem I've run into while using this and I can't seem to fix it.

After using the insert on page one and then trasferring values to page 2, I attempt to have another insert on page 2. This never works because when the page loads, it automatically redirects to the redirect url of page 2! It skips over the insert of page two. I need the two pages because I am getting the record ID number from the first insert and inserting it into another table so that they relate.

How do you fix this?

How does it work with PURE ASP ULOAD????
August 21, 2002 by Herman Van Aken
Great tutorial but how does it works on a Upload File form with Pure Asp Uplaod extension? Please help me !
"Does't support " isn't a awnser !
August 21, 2002 by Herman Van Aken
I know I asked a lot but help me with this tutorial (pass Form Values Redirect url) on PURE ASP UPLOAD ! There are many people looking out for it ! HELP!
Only need to pass two form variables ...
September 25, 2002 by Eduardo Gomez

Great way to pass all the form variables. But what if I have too many, and some of them are whole notes fields? I only need to pass two or three variables. How do I go about it? Thanks. -Eduardo

Building On ...
February 11, 2003 by Mike Peters

As the above works really well, you also have the option to put each form field into a variable or session.  This way your information is not visibly passed in the URL.

For example, session("firstname") = Request.Form("firstname") and then on your second page you could put *<%= Session("firstname")%>*.

NOTE:  This should be before your insert/edit code as that includes a redirect page and your information will not be stored into your variable or session.

RE: Building On ...
February 11, 2003 by Mike Peters

I think this will be the best method to any of our madness though:

http://www.macromedia.com/support/ultradev/ts/documents/sb_qs_redirect.htm