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

Request.ServerVariables("SCRIPT_NAME") with a parameter?

Status
Not open for further replies.

snix1

Programmer
Dec 12, 2000
107
US
I have the following form. It is a "passive" login. This form is in a sidebar of my site. The user logs in and all the action does is store a cookie, then return to the page you're on. It works fine except when the page the user is currently viewing when they decide to log on has a parameter attached to it: The "ref" input value in the form tells the action where to redirect to, but how do I append the parameter to the value? I'm relatively new at ASP and was wondering if anyone could help. I get errors if the parameter is not present, of course. I hope this makes sense. Thanks!

<form method=&quot;post&quot; name=&quot;loginform&quot; action=&quot;/login/login_action.asp&quot;>
<table>
<tr>
<td class=&quot;whiteletter&quot;>Username:
</td>
<td><input name=&quot;username&quot; type=&quot;text&quot; size=&quot;5&quot; maxlength=&quot;50&quot;>
</td>
</tr>
<tr>
<td class=&quot;whiteletter&quot;>Password:
</td>
<td><input name=&quot;password&quot; type=&quot;password&quot; size=&quot;5&quot; maxlength=&quot;50&quot;>
</td>
</tr>
<tr>
<td class=&quot;whiteletter&quot;>
<input style=&quot;background-color : white; font-size : 8pt&quot; type=&quot;submit&quot; value=&quot;GO&quot;>
</td>
</tr>
<input type=&quot;hidden&quot; name=&quot;ref&quot; value=&quot;<%=Request.ServerVariables(&quot;SCRIPT_NAME&quot;)%>&quot;>
</form>
 
<input type=&quot;hidden&quot; name=&quot;ref&quot; value=&quot;<%=Request.ServerVariables(&quot;SCRIPT_NAME&quot;) & Request.QueryString%>&quot;>

codestorm
Fire bad. Tree pretty. - Buffy
Kludges are like lies.
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>
 
Thanks so much for your response. But don't I have to have the &quot;?&quot; in there somewhere. Maybe this would work:

<%=Request.ServerVariables(&quot;SCRIPT_NAME&quot;)%><% if not isnull(Request.QueryString) then Response.write(&quot;?&quot;) & Request.QueryString end if%>

Maybe my ASP isn't so clean, though. Does this make sense?
 
Yeah sorry wasn't (and still aren't) thinking straight - I should have tested what I wrote.

You are correct.

codestorm
Fire bad. Tree pretty. - Buffy
Kludges are like lies.
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>
 
Great! Here's what I have now in my &quot;passive&quot; login form:
<form method=&quot;post&quot; name=&quot;loginform&quot; action=&quot;/login/login_action.asp&quot;>
<table>
<tr>
<td class=&quot;whiteletter&quot;>Username:
</td>
<td><input name=&quot;username&quot; type=&quot;text&quot; size=&quot;5&quot; maxlength=&quot;50&quot;>
</td>
</tr>
<tr>
<td class=&quot;whiteletter&quot;>Password:
</td>
<td><input name=&quot;password&quot; type=&quot;password&quot; size=&quot;5&quot; maxlength=&quot;50&quot;>
</td>
</tr>
<tr>
<td class=&quot;whiteletter&quot;>
<input style=&quot;background-color : white; font-size : 8pt&quot; type=&quot;submit&quot; value=&quot;GO&quot;>
</td>
</tr>

<%
ref_value = Request.ServerVariables(&quot;SCRIPT_NAME&quot;)
if not isnull(Request.QueryString) then
ref_value = ref_value & &quot;?&quot; & Request.QueryString
end if
%>
<input type=&quot;hidden&quot; name=&quot;ref&quot; value=&quot;<%=ref_value%>&quot;>

</form>

Is Request.QueryString actually null when there is no query string? I seem to always get the &quot;?&quot; at the end of the script name in the browser window. What's wrong?

Thanks
 
It's never null because it is initialized and contains a null string (a null would mean it had no value whatsoever), you could try doing a length check instead of the isNull function:
Code:
If len(Request.QueryString) > 0 Then

-Tarwn

01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top