url encode asp (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


lu lu -> url encode asp (2/8/2002 23:07:11)

the url show the options fromthe drop boxes not the "msg" string... why is this? how can i fix it? i've chopped the code to shorten it and testing is based on Case "MBSUP-1"

<%@ Language=VBScript %>
<% Response.Buffer = true%>
<%
If appID<> "" Then
Set connDB = Server.CreateObject("ADODB.Connection")
connDB.Open "DBQ=" & Server.MapPath("..\db.mdb") & ";" & _
"DRIVER=Microsoft Access Driver (*.mdb)"
sql = "SELECT appID FROM db"
Set rs = connDB.Execute(sql)
End If

Function determineForm()

If slct > 0 Then
Select Case slct
Case 1 determineForm = "0008ebus-1" : Exit Function
Case 37 determineForm = "MBSUP-1" : Exit Function

End Select
End If

%>
<html>
<head>
</head>
<body>


<form>
<select size="1" name="appID">

<%While Not rs.EOF%>

<option value="<%=rs("appID")%>">Applicant ID > ><%=rs.Fields("appID")%></option>

<%
rs.MoveNext
Wend
%>

<option selected>select a client
</select>
<p><select>
<option selected>select a form</option>
<option value="1">MBSUP-1.pdf</option>
</select></p>
<p>
<input type="submit">
</p>
</form>

<%
strResult = LCase(determineForm())
Select Case strResult
%>
<%
Case "MBSUP-1"
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db.mdb")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "select * from table", data_source

Applicant_family_name = Trim(rs("Applicant_family_name"))
Applicant_first_name = Trim(rs("Applicant_first_name"))
mailing_address = Trim(rs("mailing_address"))
applicants_birth_day = Trim(rs("applicants_birth_day"))
applicants_birth_month = Trim(rs("applicants_birth_month"))
age_factor = Trim(rs("age_factor"))

msg = "Applicant_family_name=" & Trim(rs("Applicant_family_name")) & "&Applicant_first_name=" & Trim(rs("Applicant_first_name")) & "&mailing_address=" & Trim(rs("mailing_address")) & "&applicants_birth_day=" & Trim(rs("applicants_birth_day")) & "&applicants_birth_month=" & Trim(rs("applicants_birth_month")) & "&age_factor=" & Trim(rs("age_factor"))
Response.Redirect "MBSUP-1.pdf?msg=" & Server.URLEncode(msg)

rs.Close
%>

</body>

</html>
<%
End Select
%>





Spooky -> RE: url encode asp (2/9/2002 14:29:12)

If you stop the script like this, does it show msg?

.....
"&age_factor=" & Trim(rs("age_factor"))

response.write msg
response.end

Response.Redirect "MBSUP-1.pdf?msg=" & Server.URLEncode(msg)

§þððk¥
Database / DRW Q & A
VP-ASP Shopping cart
Spooky Login




lu lu -> RE: url encode asp (2/9/2002 14:45:54)

If i use response.write i get this:
fname=john&lname=smith
which is correct but (and i'm not sure if this is a problem) the browser url has:
?appID=2&slct=1 in it.

When the pdf opens the pdf opening screen has appID=2&slct=1
What i assume is happening is the msg=" " is not writing to the url encoded but appID=2&slct=1 is. (i just created a pdf with field appID and field slct and it was populated with values 2 & 1 respectivly.

Fo some reason (unkonwn to me) the appID and slct values are being transfered to the test.pdf... not teh db field names and values.

If you seen the reason why this might be happening could you PLEASE let me know.

<%@ Language=VBScript %>
<% Response.Buffer = true%>
<%
slct = CInt(Request("slct"))
appID = CInt(Request("appID"))

If appID<> "" Then
Set connDB = Server.CreateObject("ADODB.Connection")
connDB.Open "DBQ=" & Server.MapPath("..\employsolca\database.mdb") & ";" & _
"DRIVER=Microsoft Access Driver (*.mdb)"
sql = "SELECT appID FROM table1"
Set RS = connDB.Execute(sql)
End If
%>
<html>
<head>
</head>
<body>


<form>
<select size="1" name="appID">

<%While Not RS.EOF%>

<option value="<%=RS("appID")%>">Applicant ID > ><%=RS.Fields("appID")%></option>

<%
RS.MoveNext
Wend
%>

<option selected>select a client
</select>
<p><select size="1" name="slct">
<option selected value="0">select a form</option>
<option value="1">test.pdf</option>
</select></p>
<p>
<input type="submit">
</p>
</form>
<%
Function determineForm()

If slct = 1 Then
determineForm = "test.pdf" : Exit Function
End If
End Function
%>
<%
strResult = LCase(determineForm())
Select Case strResult
%>
<%
Case "test.pdf"
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("database.mdb")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "select * from table1 where (appID = " & appID & " )", data_source
%>
<form method="GET" action="test.pdf">
<%
fname = Trim(rs("fname"))
lname = Trim(rs("lname"))

msg = "fname=" & Trim(rs("fname")) & "&lname=" & Trim(rs("lname"))

Response.Redirect "test.pdf?msg=" & Server.URLEncode(msg)

rs.Close
Set rs = Nothing
End Select
%>
</form>
</body>
</html>

This is the directions i'm suspose to follow to make this work:
"This approach is very simple, you put the javascript in the pdf file then submit a form to the pdf file using the GET method. The javascript will populate only the fields who's names match those in the header, the others will be ignored.


Edited by - lu lu on 02/09/2002 15:47:24




lu lu -> RE: url encode asp (2/9/2002 18:48:51)

i fixed it, the encoded url now pass with the redirect this this the working code, i havn't compared it to the previous post but after hours of fiddling it works:
<%@ Language=VBScript %>
<% Response.Buffer = true%>
<%
slct = CInt(Request("slct"))
appID = CInt(Request("appID"))

If appID<> "" Then
Set connDB = Server.CreateObject("ADODB.Connection")
connDB.Open "DBQ=" & Server.MapPath("..\employsolca\database.mdb") & ";" & _
"DRIVER=Microsoft Access Driver (*.mdb)"
sql = "SELECT appID FROM table1"
Set rs = connDB.Execute(sql)
End If
%>
<html>
<head>
</head>
<body>


<form>
<select size="1" name="appID">

<%While Not rs.EOF%>

<option value="<%=rs("appID")%>">Applicant ID > ><%=rs.Fields("appID")%></option>

<%
rs.MoveNext
Wend
%>

<option selected>select a client
</select>
<p><select size="1" name="slct">
<option selected value="0">select a form</option>
<option value="1">test.pdf</option>
</select></p>
<p>
<input type="submit">
</p>
<%
Function determineForm()

If slct = 1 Then
determineForm = "test.pdf" : Exit Function
End If
End Function
%>
<%
strResult = LCase(determineForm())
Select Case strResult
Case "test.pdf"
%>

<%
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("database.mdb")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "select * from table1 where ( appID = " & appID & " )", data_source

fname = Trim(rs("fname"))
lname = Trim(rs("lname"))

msg = "fname=" & Trim(rs("fname")) & "&lname=" & Trim(rs("lname"))
Response.Redirect "test.pdf?msg=" & Server.URLEncode(msg)
%>
</form>
</body>
<%
End Select
%>
</html>





Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.078125