Manually passing form data to classic asp page fails - html

Passing form values to the asp page from a standard html form works, but trying to pass them manually does not. Is this some oddity with ASP classic? To outline the situation, I have the following standard form:
<form name="login" id="login" method="post" action="login_process.asp">
<input name="userName" type="text" size="30" maxlength="100" />
<input name="password" type="password" size="30" maxlength="100" />
<input name="Submit" type="submit" class="btn" value="Login" />
</form>
On the receiving end (login_process.asp), I have this:
if Request.Form("Username") <> "" and Request.Form("Password") <> "" then
' do stuff here
Now the odd thing is that this form has been in place for years and actually works. But if I try passing values manually to login_process.asp the values never make it:
www.zzz.com/login_process.asp?username=some_user&password=some_password
I added some checks to login_process.asp to see if I could pull the vars from the submit before they were processed like so:
myUsername = request.form("Username")
myPassword = request.form("Password")
response.write "user=" & myUsername
response.write "pass=" & myPassword
and all I'm getting is
user=pass=
So obviously the data isn't getting passed. But why? What am I overlooking? Passing form data is basic stuff so what gives?
Any insights appreciated!

You are no longer using the form if you are passing them on the querystring, So Request.Form won't work. You need to use Request.QueryString instead.
More info here

We can use "Request.Form" to get form field data into other page. For this please try below code :
<form name="login" id="login" method="post" action="login_process.asp">
<input name="userName" type="text" size="30" maxlength="100" />
<input name="password" type="password" size="30" maxlength="100" />
<input name="Submit" type="submit" class="btn" value="Login" />
</form>
And we get the form data in login.process.asp page is something like this :
<% Response.Write(Request.Form("userName")) %>
It will display userName value

Related

The preventDefault() isn't working, how can I make it so, that it works correctly?

The preventDefault() isn't working correctly. When I press the Login button, the page refresh's, but with the preventDefault() it shouldn't.
I tried it with stopPropagation(), but there was the same problem.
TypeScript:
loginUser(loginevent){
loginevent.preventDefault()
const target = loginevent.target
const username = target.getElementById('username')
const password = target.getElementById('pasword')
console.log(username, password)
}
HTML:
<form (submit)="loginUser($loginevent)">
<input type="text" placeholder="Benutzername" id="username">
<input type="text" placeholder="Passwort" id="password">
<input type="submit" value="Login">
</form>
The loginevent.preventDefault() should prevent the page from reloading it, when I press the Login button.
You'd have to pass $event as an argument and not any other word. $event is a reserved keyword to get the event data.
Here's what the Angular Docs say:
The framework passes the event argument—represented by $event—to the handler method, and the method processes it:
Try this:
<form (submit)="loginUser($event)">
<input type="text" placeholder="Benutzername" id="username">
<input type="text" placeholder="Passwort" id="password">
<input type="submit" value="Login">
</form>
I would suggest you should use what angular has to offer, either a template-driven or reactive form. We are coding with angular, then why not do it the angular way :)
Template driven:
<form #f="ngForm" (ngSubmit)="loginUser(f.value)">
<input type="text" placeholder="Benutzername" name="username" ngModel>
<input type="text" placeholder="Passwort" name="password" ngModel>
<button type="submit">Submit</button>
</form>
Here you now pass the form value to your login, which contains your username and password:
loginUser(values){
const username = values.username
const password = values.password
console.log(username, password)
}
With this, you don't even need to worry about preventDefault()
But I would also recommend the reactive way, read more about both template-driven and reactive forms: https://angular.io/guide/forms

Hide form input fields from URL

I've got a login form with two input fields: username and password.
<form method="get" action="../Main/Index">
<p>
<input type="text" name="username" value="" placeholder="username" maxlength="30"></p>
<p>
<input type="password" name="password" value="" placeholder="password" maxlength="25"></p>
<p class="submit">
<input type="submit" name="commit" value="Enter">
</p>
</form>
Once the user submits the form, his username and password are shown in the browser's URL textbox, something like this:
http://localhost:53997/Main/Index?username=zm&password=123456789&commit=Enter
I don't want his username and password to be on display.
How can I do this?
the problem is that youre using form method = "get" when you should be using form method = "post" instead.
this explains it:
http://msdn.microsoft.com/en-us/library/ee784233(v=cs.20).aspx

input text value

ok this is it... i need to submit a form where the user enters a info in a input box but the value has other text aswell.
for example: user - enters 123 value is - www.helloneed123help.com submit
the 123 from the url is what the user entered
this is code i have:
<form name="postcode" method="post" action="location.html">
<input type="text" name="post" id="post" required="required" maxlength="8" />
<input type="submit" name="submit" value="submit" class="submit" />
</form>
any ideas? sheraz
No jQuery needed, straight JavaScript.
Add the following directly after the form HTML:
<script>
document.forms.postcode.onsubmit = function(){
this.post.value = 'www.helloneed' + this.post.value + 'help.com';
alert(this.post.value);
}​
</script>
Fiddle:
http://jsfiddle.net/iambriansreed/ZeKUq/
Just add 'onclick' event in input tag and write javascript code there.
<input type="submit" name="submit" value="submit" class="submit" onclick="post.value='www.helloneed' + post.value + 'help.com';" />
You could try prepending & appending text to the value of the inputbox.
e.g. onsubmit="$('#post').val('http://www.helloneed' + $('#post').val() + 'help.com');
This may work:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<form name="postcode" method="post" action="location.html" onsubmit="$('#post').val('http://www.helloneed' + $('#post').val() + 'help.com'); return false">
<input type="text" name="post" id="post" required="required" maxlength="8" />
<input type="submit" name="submit" value="submit" class="submit" />
</form>
(After your first test, I would remove the return false text)
Andrew
It is not possible to do this in HTML. Such issues should be handled server-side.
It’s easy to do this in JavaScript, as outlined in iambriansreed’s answer, but it’s equally simple and much more robust to do it server-side. In a case like this, there isn’t even any need to do it client-side as well; it would just complicate things, as the server-side code would have no direct way of knowing what it gets (direct user input vs. input modified by client−side JavaScript when enabled).

Passing parameter and user input

I am trying to pass a few parameter and a user input to a search_form.asp page.
<form action="search_form.asp" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
</form>
And on search_form.asp...
lname=request.QueryString("Lname")
fname=request.form("fname")
But I am unable to see lname when i place Response.Write("<p>Name: " & lname) in search_form.asp
The query string is not preserved when you submit the form, so search_form.asp will not have a query string. As an alternative, could you include the query string as a hidden field:
<form action="search_form.asp" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
<input type="hidden" name="lname" value="<%=Request.QueryString("lname")%>" />
</form>
And then refer to Request.Form("lname") in search_form.asp.
Alternatively, could you include the query string in the form action?
<form action="search_form.asp?<%=Request.ServerVariables("QUERY_STRING")%>" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
<input type="hidden" name="lname" value="<%=Request.QueryString("lname")%>" />
</form>
This should pass the query string on the original page when the form is submitted.

Posting a link as Submit Button

<form method="POST" action="auth/signin">
Username: <input name="username" type="text" value=""/>
Password: <input name="password" type="password" value=""/>
Log In
</form>
How do I post the parameters when the "Log In" link is clicked (instead of using the submit button)?
I think you need Javascript, something like this:
Log In