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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Build URL

Status
Not open for further replies.

Webflex

Technical User
Apr 20, 2001
101
GB
Hi moving on from a previous problem, I am trying to use the code below to pick up a username and build it into a URL as below, only problem is it does not work, it automatically goes to the notes.asp page, how do i stop it to pick up the username then go to the login page and go to the notes.asp if the field is blank.

Thanks
---------------------------------------------------------

Code:
<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<%
dim username
dim url
username = request.querystring(&quot;username&quot;)
%>
<% 

if Len(username) < 1 then 
URL = &quot;[URL unfurl="true"]http://intranetuk1/notes.asp&quot;[/URL]
response.redirect(url)
%>

<html>
<head>
<title>NotesMail Login</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>


<form name=&quot;inputname&quot; method=&quot;post&quot; action=&quot;noteslogin.asp&quot;>
  <input  type=&quot;text&quot; name=&quot;username&quot; size=&quot;20&quot;>
 <input  type=&quot;submit&quot; name=&quot;continue&quot; value=&quot;submit&quot;>
</form>
<%
else
response.redirect(&quot;[URL unfurl="true"]http://uk01-s005/&quot;[/URL] & username & &quot;.nsf&quot;)
end if 
%>
</body>
</html>
 
URL = &quot;response.redirect(url)


the problem is this above, if the username is less than 1 then the script is automatically sending them to notes.asp

as an example just add a ' to the front of each then run the script....

URL = &quot;'response.redirect(url)

it will then work... the ' tells it to ignore them lines
 
OK that made it stop going to notes.asp but it still will not go to as below

----------------------------------------------------

Code:
<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<%
dim username
dim url
dim URL2
username = request.querystring(&quot;username&quot;)
%>
<% 

if Len(username) < 1 then 
URL = &quot;[URL unfurl="true"]http://intranetuk1/notes.asp&quot;[/URL]
'response.redirect(url)
%>

<html>
<head>
<title>NotesMail Login</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>


<form name=&quot;inputname&quot; method=&quot;post&quot; action=&quot;noteslogin.asp&quot;>
  <input  type=&quot;text&quot; name=&quot;username&quot; size=&quot;20&quot;>
 <input  type=&quot;submit&quot; name=&quot;continue&quot; value=&quot;submit&quot;>
</form>
<%
else
URL2 = &quot;[URL unfurl="true"]http://uk01-s005/mail/&quot;[/URL] & username & &quot;.nsf&quot;
response.redirect(URL2)
end if 
%>
</body>
</html>
 
change request.querystring to request.form

the reason... you are posting the info on the form, instead of getting it... so if you change that it will then read the variable

when you did it before and where told to use querysting, the reason is becuase we didnt use the method=&quot;post&quot; option so it was auto on get

ie

For Method=&quot;post&quot; use request.form
for Method=&quot;&quot; or method=&quot;get&quot; use request.querystring

hope that helps
 
Many thanks, fixed it... off to the pub
 
But, one question how can I reintroduce the error trap for zero length passwords ?
 
ok

you can do it as follows
in the form section add a second field as follows

<input type=&quot;hidden&quot; name=&quot;done&quot; value=&quot;yes&quot;>

then at the top you can have

if Len(username) < 1 and request.form(&quot;done&quot;) = &quot;yes&quot; then
URL = &quot;response.redirect(url)

this will then cause the above code to run if the form has been filled in the first time... when the page first opens the variable done will not exist so it will not run the coding
 
thankyou - definitely off to the pub now
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top