Posting a link as Submit Button - html

<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

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

Form not taking action

I have a problem with a form. It is not sending any action (page not even refreshing on click). If I copy the form in another document locally it has no problem, all working well, mail message being sent. Here is the code of the form:
<form method='post' name='ContactForm' id='contactForm' action='contact_main.php'>
<p>Your name:</p>
<input type="text" class="input-box" name="user-name" placeholder="Please enter your name.">
<p>Email address:</p>
<input type="text" class="input-box" name="user-email" placeholder="Please enter your email address.">
<p>Subject:</p>
<input type="text" class="input-box" name="user-subject" placeholder="Purpose of this message.">
<p class="right-message-box">Message:</p>
<textarea class="input-box right-message-box message-box" name="user-message" placeholder="Your message."></textarea>
<button type='submit' class='myinputbtn' name='submitf' id="submitf">Send your message</button>
<div id='message_post'></div>
<input type="hidden" name="contact">
</form>
Clicking the submit button results in... nothing!
Please let me know if I need to edit my question before downrating. Thanks!
Use
<input type="submit" ...
instead of a button (which is used with Javascript, not for form submitting)

Manually passing form data to classic asp page fails

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

Chrome browser saving form inputs- what names/IDs used and why only some saved?

I have a page on my site with two forms, one for log in and one for registering.
LOG IN-
<form name="login" id="login" method="post" action="php/login.php">
Email: <input id="email" name="email" type="text">
Password:<input id="password" name="password" type="password">
</form>
REGISTER-
<form id="register" name="register" method="post" action="php/register.php">
Email: <input id="r_email" name="r_email" type="text">
Confirm Email: <input id="r_email_confirm" name="r_email_confirm" type="text">
Password: <input id="r_password" name="r_password" type="password">
Confirm Password:<input id="r_password_confirm" name="r_password_confirm" type="password">
</form>
When I've tested it, Chrome is saving the log in form's email and password (id email and password) and the register form's confirm email and password (id r_email_confirm and r_password).
Any ideas why it is saving these values?
Seems it's been an issue in Chrome:
http://productforums.google.com/forum/#!topic/chrome/f6zhGC8lVw4
It's been recommended to use
<form autocomplete="off"...
for the time being, which is a bit annoying.