Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to pass text from one ASP to another (hidden)

Status
Not open for further replies.

ASmee

IS-IT--Management
Jul 9, 2002
46
0
0
US
I have an asp that is checking a username and password and if found redirecting to another asp (welcome.asp). I want to pass some hidden text to welcome.asp so that when it executes it will only show the details for a valid user:

welcome.asp reads:

<%

gre = request.form("h1")

if ucase(gre) = "BLACK_ON_GREEN" then
response.write("<HTML><BODY><BR>Hello world</body></html>")
else
response.redirect "noway.asp"
end if
%>

The previous ASP reads:

response.write("<html><form method='post' action=''><input name='h1' type='hidden' VALUE='Black_on_green'></form></html>)
response.redirect "welcome.asp"

When I am redirected to welcome.asp it then redirects me to noway.asp when it should welcome me. What am I doing wrong?
 
In your action attribute of your form tag add welcome.asp.

I'm not sure but you may need a submit button somewhere in there as well.
 
Yeah I tried that, it never redirects to welcome.asp just hangs on the previous asp file.

Having a submit button is not really an option. Perhaps I am looking at this from the wrong angle? How do you control the loading of an ASP file?
 
response.redirecting doesn't actually submit the form, so the request.form("h1") isn't populated.
Try something like this in your form page:
Code:
<%
response.write("<html><form name='test' method='post' action='welcome.asp'><input name='h1' type='hidden' VALUE='Black_on_green'></form></html>")

%>
<Script language='vbscript'>
<!--
sub window_onload
test.submit
end sub
-->
</script>

You can put
response.write request.form
response.end
at the beginning of welcome.asp until you're sure the variable is being passed.
 
Redirect does not submit the form with out a submit button nothing will be passed to welcome.asp that what your if statement fails.

if you want to pass a value with out a submit button try this :

response.redirect "Welcome.asp?h1=black_on_green"

then on welcome.asp
do this :

<%

gre = request.QueryString("h1")

if ucase(gre) = "BLACK_ON_GREEN" then
response.write("<HTML><BODY><BR>Hello world</body></html>")
else
response.redirect "noway.asp"
end if
%>

if you dont want to do that try Sessions :


first page use:

Session("h1") = "black_on_green"

response.redirect "Welcome.asp"




Then on welcome.asp use

<%

gre = Session("h1")

if ucase(gre) = "BLACK_ON_GREEN" then
response.write("<HTML><BODY><BR>Hello world</body></html>")
else
response.redirect "noway.asp"
end if
%>

you will pass the data in the session to the next page and use it on welcome.asp

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top