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
Related
When I fill input login form, input form shows me previous login. How can I hide or don't display previous login.
I try to change type of input to type = "hidden", but this hide was displayed like password type;
<form method="POST">
<label for = "adminLogin">Login: </label>
<input name = "adminLogin" type="hidden" >
<input type="submit" value="Log in">
</form>
You can use autocomplete="off" to tell the browser not to show suggestions:
<form method="POST">
<label for = "adminLogin">Login: </label>
<input name = "adminLogin" autocomplete="off" >
<input type="submit" value="Log in">
</form>
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
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)
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.
<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