This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > February 2006 > Response.Redirect with Dyanmic variable





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Response.Redirect with Dyanmic variable
Wally Kolcz

2006-02-12, 6:33 pm

I want to have a page (which is dynamic) return to itself with a page
variable using the response.redirect.

I have this <%Response.Redirect("proof_details.asp?status=updated)%>

It works fine, but the page is dynamic and has the projectid number in the
URL. When it returns, using the response.redirect, it looses the projectid
variable.

How can I add it dynamically to the Response.Redirect?

Projectid = project.Fields.Item("projectid").Value)

Thanks! ASP/VB
--
Wally Kolcz
Developer / Support
ProjectProofing.com


Chris In Madison

2006-02-12, 6:33 pm

After the project ID value is placed in teh Projectid variable, you can use
it anywhere on the page after that. For your redirect, it would be:

<% response.redirect("proof_details.asp?status=updated&projectid=" &
Projectid) %>

That way, when the page is reloaded, the project id is available to the
request object. Be warned, though. This could easily lead to a SQL
injection attack if you don't account for it in your code. You might be
better off passing this info around in a session variable:

<% Session("current_projectid") = project.Fields.Item("projectid").Value %>

Then you can grab that session variables value anywhere and anytime it's
needed without passing the info through the query string.

Just a couple of thoughts off the top of my head. There are probably other
ways to do it as well.

Best regards,
Chris


Wally Kolcz

2006-02-12, 6:33 pm

Thanks.

So, if I use the Session way I would then change my statement to:

<% response.redirect("proof_details.asp?status=updated&projectid=" &
current_projectid) %>

to account for the new session name?
--
Wally Kolcz
Developer / Support
ProjectProofing.com


> After the project ID value is placed in teh Projectid variable, you can
> use
> it anywhere on the page after that. For your redirect, it would be:
>
> <% response.redirect("proof_details.asp?status=updated&projectid=" &
> Projectid) %>
>
> That way, when the page is reloaded, the project id is available to the
> request object. Be warned, though. This could easily lead to a SQL
> injection attack if you don't account for it in your code. You might be
> better off passing this info around in a session variable:
>
> <% Session("current_projectid") = project.Fields.Item("projectid").Value
> %>
>
> Then you can grab that session variables value anywhere and anytime it's
> needed without passing the info through the query string.
>
> Just a couple of thoughts off the top of my head. There are probably
> other
> ways to do it as well.
>
> Best regards,
> Chris
>
>



Chris In Madison

2006-02-12, 6:33 pm

I guess it depends on what you need to do on the proof_details.asp page.
Does it require the project ID? If so, and you use the session method, then
don't try to pass it in the querystring. You can keep it like you had it
before:

<% response.redirect("proof_details.asp?status=updated") %>

Then, on the proof_details.asp page, in the place you need to consume the
project ID, you could simply use:

<% MyProjectID = Session("current_projectid") %>

and use that variable where you need it. The important thing to note about
this method is the only way to get to the value is through your code, and
someone can't get at something they're not supposed to get at by randomly
placing project ID numbers in the querystring.

Does that make sense? I'm not sure I directly answered your question...

Best regards,
Chris


Wally Kolcz

2006-02-12, 6:33 pm

It does require the project id based on the users select on the previous
page. It is what pulls the information from the database to populate the
page.

--
Wally Kolcz
Developer / Support
ProjectProofing.com


Chris In Madison

2006-02-12, 6:34 pm

Okay then. So your options are either of those I mentioned before. You can
either pass the project ID in the querystring and grab it with the Request
object:

<%
Projectid = project.Fields.Item("projectid").Value
response.redirect("proof_details.asp?status=updated&projectid=" & Projectid)
%>

Or set it in the Session object and grab the session variable when the page
loads again:

<%
Session("Projectid") = project.Fields.Item("projectid").Value
project.Close()
set project = Nothing
response.redirect("proof_details.asp?status=updated)
%>

With the second option just make sure you systematically clear the Projectid
session variable when you're done with it so you don't accidentally change
the status of anything that shouldn't be.

Best regards,
Chris


Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews