Can Querystring be used to fill in Target Page Data?

D

daforga

I am validating page input on a server page. If the test passes, a task is
performed, if it fails, the user should be sent back to the origional page
with the correctly submitted variables still showing. The test holds, but I
am having trouble finding the code to re-show the variables on return. I am
currently using the code as follows (it's a trimmed down version of my pages.
)
If and when I get this working my further question is :
Is there a better way of doing this? I have to validate on the server.
Can anyone help me with this?
Thanks

Here is the calling page:
<%@ Language=VBScript %>
<HTML>
<HEAD>
<title>Test</title>
</HEAD>
<body>
<form id="InfoRequest" action="page2.asp" method="post"
name="FrontPage_Form1">
<table width="400" border="0" cellspacing="0" cellpadding="3" ID="Table4">
<tr bgcolor="#336699">
<td>
<input id="text1" name="KeepName1">
</td>
<td>
<input id="Text2" name="KeepName2">
</td>
</tr>
<tr>
<td bgcolor="#336699">
<font color="white"><b>Value one - Keep on return </b></font><font
face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">
</font>
</td>
<td bgcolor="#336699">
<font color="white"><b>Value two - Keep on return </b></font><font
face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">
</font>
</td>
</tr>
<tr bgcolor="#336699">
<td>
<input id="Text7" name="_text7" value="zzz">
</td>
<td>
<input id="text" name="_CaptchaBox">
</td>
<tr>
<td bgcolor="#336699">
<font color="white"><b>This is a constant </b></font><font
face="Arial, Helvetica, Geneva, Swiss, SunSans-Regular">
</font>
</td>
<td bgcolor="#336699">
<font color="white"><b>Clear on return</b></font><font face="Arial,
Helvetica, Geneva, Swiss, SunSans-Regular">
</font>
</td>
</tr>
<tr height="25" bgcolor="#336699">
<td colspan="2" height="25">
<input type="submit" value="Submit" ID="Submit2" NAME="_Submit2">
</td>
</tr>
</table>
</form>
<hr>
<p></p>
</TD></TR></TABLE> <map name="phonebc0a3c7c"></map><map
name="womanbc0a1b76"></map>
<map name="roambc0a1b94">
<area shape="RECT" coords="2,1,149,68" href="rivfin_roam.html">
</map>
<p></p>
<DIV></DIV>
</body>
</HTML>

Here is the page with the Redirect back to origional page:
<%@ Language=VBScript %>
<%
If Trim(UCase(Request("_CaptchaBox"))) = Trim(UCase(Request("_text7")))then
Response.Write("Good" + Request("_CaptchaBox") + " ")
Response.Write(Request("_text7"))
else
Response.Redirect("page1.asp?Keepname1" +
Request("KeepName1")
+"&KeepName2" + Request("KeepName2"))
end if
%>
 
A

Adrienne Boswell

Gazing into my crystal ball I observed =?Utf-8?B?ZGFmb3JnYQ==?=
I am validating page input on a server page. If the test passes, a
task is performed, if it fails, the user should be sent back to the
origional page with the correctly submitted variables still showing.
The test holds, but I am having trouble finding the code to re-show
the variables on return. I am currently using the code as follows
(it's a trimmed down version of my pages. )
If and when I get this working my further question is :
Is there a better way of doing this? I have to validate on the
server. Can anyone help me with this?
Thanks

Although the first part of my response is off topic for this group, I
feel compelled to write this anyway.

The markup you are using is truly outdated. The FONT element has been
deprecated in favor of CSS for quite some time. Using HTML elements is
a pain to markup, and an even bigger pain to maintain. Using tables for
positioning of elements is a bad idea - a maintenance nightmare. Use
tables for tabular data, and CSS to position elements.
Here is the calling page:
<%@ Language=VBScript %>
<HTML>

You need to put a doctype declaration in there. Use Strict.
<HEAD>
<title>Test</title>
</HEAD>
<body>
<form id="InfoRequest" action="page2.asp" method="post"
name="FrontPage_Form1">

Oh boy, are you using Front Page? Please, in all seriousness, get rid
of that program. If you insist on using a WYSIWYG, then at least get
one that writes better markup - I've heard the NVU and Expression Web
(MS) do a pretty good job.

You would also be better to post the information to the page itself,
instead of another page. That way, you will not have as many issues
with returning the user to the page with the content intact.
 
D

daforga

Sorry to offend with the bad code. I am working on an old site and have used
what is there already. Can my question be answered in spite of this fact?
 
A

Adrienne Boswell

Gazing into my crystal ball I observed =?Utf-8?B?ZGFmb3JnYQ==?=
<[email protected]> writing in

Please do not top post. I have put your response at the end of the
message.
Sorry to offend with the bad code. I am working on an old site and
have used what is there already. Can my question be answered in spite
of this fact?

Yes, as I said, better to post to the same page.

I had a similar experience a few years ago, and while I was in there
doing ASP coding, I cleaned up the markup at the same time. You could
do that, too. Trust me, if you clean up the markup now, you will have
less maintenance headaches in the future.

You might also find it easier to make form field names something
meaningful, like what the field does, eg: firstname for first name.
Usually, I name my form fields the same as the fields in my db table.
Then mapping becomes very easy because I don't have to think about what
textfield7 maps to in the db table.

Please note the example below is very, very simple, just only there to
show how a simple form can be built to post to the same page. Note that
there is javascript which erases the default value when the user first
opens the form.

<% option explicit

dim ispost, isget
dim wholename, email
dim required, message

if request.servervariable("Request_Method") = "POST" then
ispost = true
elseif request.servervariables("Request_Method") = "GET" then
isget = true
end if

if ispost then
'validate input
wholename = request.form("wholename")
email = request.form("email")
if wholename = "" or wholename = "Your whole name" then
required = "wholename"
end if
if email = "" or email = "(e-mail address removed)" then
required = "email"
end if

if required <> "" then
message = required & " is required"
else
'do whatever you are going to do with the data"
end if
else
wholename = "Your whole name"
email = "(e-mail address removed)"
end if
%>

<%=message%>
<form method="post" action="<%=request.servervariable("SCRIPT_NAME")%>">
<fieldset><legend>Fill in your information</legend>
<label for="wholename">Whole Name: </label> <input type="text"
name="wholename" value="<%=wholename%>" id="wholename" <%if isget then%>
onfocus="if(this.value == '<%=wholename%>') this.value = '';"<%end if
%>><br>
<label for="email">Email: </label> <input type="text" name="email"
id="email" value="<%=email%>" <%if isget then%>onfocus="if(this.value ==
'<%=email%>') this.value = '';"<%end if %>>
<p><input type="submit" value="Submit"></p>
</fieldset>
</form>
 
D

daforga

Thank you so much. I am at work now and will update this post as the work
proceeds.
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top