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!

can you "fake" a forms post using asp?

Status
Not open for further replies.

dnk

Technical User
Mar 23, 2001
15
0
0
US
is there a way to "fake" a forms post using asp? i want to call some pre-built (not changable) search pages that normally get input from users in a form, but i would like to programmatically force the form-fields so that search engine responds as if someone had typed in the arguments. the existing pages unfortunately use Request.Form functions to get the arguments, so i can't just dummy them onto the URL. tia dnk
 
use hidden fields in your forms to force the form field values:

<input type=&quot;hidden&quot; name=&quot;first_field&quot; value=&quot;first value&quot;>
 
thanks, but i guess i didn't make my question clear enough. i have a database full of names of people with expertise in various areas in our company. we have a corporate phonebook on our intranet, which people can use to lookup phone numbers, etc. they type the target name into a form, which feeds an asp page that looks up the name in the corporate phonebook.

i just want to &quot;fake&quot; a call to that phonebook by looking up a known name and doing a faked call to the searcher. i can't change the search page, or get direct access to the phonebook, for &quot;security&quot; reasons.

for instance, if the (unchangable) search page did a Request.Querysting(&quot;name&quot;) i could just make a URL with &quot;?name=xxx&quot; in it. but the (unchangable) search page apparently does a Request.Forms(&quot;name&quot;) instead, so my hack won't work.

there must be a way to fake a post to the form field though -- i can't generate a form with a hidden field because i want to get to the (unchangable) search page by using a Response.Redirect after i've looked up the name - and if i build the hidden form field thing the Redirect will fail because it would have been a body write.

any ideas???
 
Somewhat what lobstah has stated, but with a bit of elaboration:

You could literally response.write() the whole page including the hidden form variables with the variables that you want -- this could all be done with ASP.

You would also need a javascript submit function that would look something like:

<script language=javascript>
function submitMe(){
document.formName.submit();
}
</script>

and then call that function:

<body onLoad=&quot;submitMe();&quot;>

So that when the page loads, the form will be submitted to your script that does the lookup for you -- no user interaction allowed (much less needed).

hope that helps! :)
paul
penny.gif
penny.gif
 
THANKS! that's what i love about this place, sometimes it just takes a fresh set of eyes to make you look at a problem a different way. that was perfect, and very short:

<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<% nameStr = Request.QueryString(&quot;userName&quot;) %>
<html>
<script language=javascript>
function submitMe() {
document.fakeform.submit();
}
</script>
<body onLoad=&quot;submitMe();&quot;>
<form method=&quot;POST&quot; name=&quot;fakeform&quot; action=&quot;<input type=&quot;hidden&quot; name=&quot;userName&quot; value=&quot;<%=nameStr%>&quot;>
</form>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top