I'm trying to create a login page in php.
I got the form and the login verificaion works fine but when i go to my index.php which is my log in page, the login credentials are auto filled with unwanted credentials like below.
Whereas my login paage should look like this..
My form is as below:
<form action="check_login.php" method="post">
<label id="uname">User Name: </label><input type="text" placeholder="Enter Username" name="uname" required="required"> <br>
<label id="psw">Password: </label><input type="password" placeholder="Enter Password" name="psw" required="required"> <br> <br>
<button type="submit" name="login">Login </button>
</form>
When I use type=text it works fine..
I've also tried autocomplete="off", but it doesn't work...
What am I doing wrong? I'm a newbie... Please help me...
change
<input type="text" placeholder="Enter Username" name="uname" required="required">
with
<input type="text" placeholder="Enter Username" name="uname" required="required" autocomplete="off" />
it is browser feature to auto fill the form
"Autofilling" a form is a browser feature. You can turn it off for a form using the autocomplete attribute (setting it to off). Change your form to
<form action="check_login.php" method="post" autocomplete="off">
<label id="uname">User Name: </label><input type="text" placeholder="Enter Username" name="uname" required="required"> <br>
<label id="psw">Password: </label><input type="password" placeholder="Enter Password" name="psw" required="required"> <br> <br>
<button type="submit" name="login">Login </button>
</form>
There might be cases where autocomplete="off" is set, but the browser still fills in your form details. The "trick" is to set autocomplete to an invalid value, like autocomplete="kerbholz".
I got it...removed the user from saved logins from my browser.... And it works fine...
Related
I have user registration form. Form contains username and password field.
At the time of user registration username and password fields automatically populated values.
I have used form "autocomplete" attribute, but not working on chrome browser.
This is my code,
<form method="post" action="" autocomplete="off">
<input type="text" id="first_name" name="first_name">
<input type="text" id="last_name" name="last_name">
<input type="text" id="username_name" name="username_name">
<input type="text" id="password" name="password">
In my experience, Chrome only autocompletes the first <input type="password"> and the previous . So I added:
<input style="display:none">
<input type="password" style="display:none">
To the top of the <form> and the case was resolved.
I have a login form as below:
<form name="checkform" action="example.php">
<input type="text" id="c_email" name="c_email" placeholder="EMail here">
<input type="text" id="c_epass" name="c_epass" placeholder="Password here">
<input type="submit" id="c_sub">
</form>
Now when i use this form to Login and then browser ask to save password. I clicked yes and those are saved in browser. But i do not want to auto populate these details everytime i open the page to login.
How can i restrict not to auto populate these details? I want that if user fills email id then only saved password shall populate otherwise those fields should remain empty.
<form name="checkform" action="example.php" autocomplete='off'>
<input type="text" id="c_email" name="c_email" placeholder="EMail here">
<input type="text" id="c_epass" name="c_epass" placeholder="Password here">
<input type="submit" id="c_sub">
</form>
Use autocomplete="off" in inputbox:
<form name="checkform" action="example.php" autocomplete="off">
<input type="text" id="c_email" name="c_email" placeholder="EMail here">
<input type="text" id="c_epass" name="c_epass" placeholder="Password here">
<input type="submit" id="c_sub">
</form>
Reference is here.
How do I send information from a HTML page to a php page which then makes a connection to a database?
This is my code so far on my website: http://jsfiddle.net/xiiJaMiiE/wNraL/
<h1>
<div id=signin>
<input type="text" name="textbox1" value="Username" onfocus="if
(this.value==this.defaultValue) this.value='';" size="19%" height="50"/></br>
<input type="password" name="password" value="Password" onfocus="if
(this.value==this.defaultValue) this.value='';" size="19%" height="50"/>
</div>
</h1>
Thanks in advance!
Replace your h1 element (you don't have a heading so you shouldn't say you do) with a form element.
Give it an action attribute that specifies the URL of the PHP program you want to submit the data to.
Since you are sending authentication data, add a method attribute that to POST the data.
<form action="signin.php" method="POST">
<div id=signin>
<label>
Username
<input type="text" name="username">
</label>
<label>
Password
<input type="password" name="password">
</label>
</div>
</form>
The data will then be available to PHP via $_POST['field_name_here'].
<div id=signin>
<form action="connection.php" method="POST">
<input type="text" name="username" value="Username" onfocus="if (this.value==this.defaultValue) this.value='';" size="19%" height="50"/>
<br>
<input type="password" name="password" value="Password" onfocus="if (this.value==this.defaultValue) this.value='';" size="19%" height="50"/>
</form>
</div>
You can access these passed variables in the conneciton.php file with $_POST['username'] and $_POST['password'].
you should set the action attribute to a file that will process form data (eg process. php) and pass form data to your database using $_POST('filedName') on submitting the form.
I have just discovered that the isset function is no longer working on my login and register forms. Very strange I though, so I undid everything that I had recently done to see if it was causing it but no luck. If i remove the isset and replace with this;
if($_SERVER['REQUEST_METHOD'] == "POST"){
it works! But I have two forms on one page so I need to check which one is submitted.
Here's the isset function:
if (isset($_POST['submit_login'])) {
And the submit button just so you know it has the correct name;
<input type="submit" name="submit_login" value="Login" class="buttonClassic"/>
The one for the register form is exactly the same but with name submit_reg.
Form:
<form action="<?php echo htmlentities('Login'); ?>" method="post" id="login">
<p class="p1">Already signed up? Log in</p><hr/>
<label for="email">Your email address </label><input type="email" required name="email" placeholder="Email" class="text" id="email">
<label for="password">Your password </label><input type="password" name="pass" required placeholder="Password" class="text" id="password">
<center><input type="submit" name="submit_login" value="Login" class="buttonClassic"/></center>
<div class="center-align-text">
<p class="p3">Forgotten your password?</p>
</div>
</form>
reg form:
<form action="<?php echo htmlentities('Login'); ?>" method="post" id="register" >
<p class="p1">New to NBS? Sign up, it's free!</p><hr/>
<label for="reg_email">What's your email address? </label><input type="email" name="email" required placeholder="Email" class="text" id="reg_email">
<label for="reg_password">Choose a password </label><input type="password" required name="pass" placeholder="Password" class="text" id="reg_password">
<label for="reg_password2">Re-type password </label><input type="password" required name="pass2" placeholder="Re-type password" class="text" id="reg_password2">
<input type="checkbox" name="subscribed" value="subscribed" id="subscribed"><label for="subscribed">Yes, send me email updates from NewBorn Sounds. </label>
<br/>
<input type="checkbox" required="flag" name="terms" value="ticked" id="terms"><label for="terms">I agree to the terms & conditions.</label>
<center><input type="submit" name="submit_reg" value="Sign Up" class="buttonClassic"></center>
</form>
If you need anything more just shout!
Oh and I know I could just submit the form to an external PHP script but I don't particularly want to do that as I would like the user input errors to be outputted to the same page. I know I could just use ajax, which I do, but I am trying to keep javascript as an add-on and not reduce the user experience for no js.
Full HTML:
<div id="login_form_wrapper">
<form action="Login" method="post" id="login" novalidate="novalidate">
<p class="p1">Already signed up? Log in</p><hr>
<label for="email">Your email address </label><input type="email" required="" name="email" placeholder="Email" class="text" id="email">
<label for="password">Your password </label><input type="password" name="pass" required="" placeholder="Password" class="text" id="password">
<center><input type="submit" name="submit_login" value="Login" class="buttonClassic"></center>
<div class="center-align-text">
<p class="p3">Forgotten your password?</p>
</div>
</form>
<form action="Login" method="post" id="register" novalidate="novalidate">
<p class="p1">New to NBS? Sign up, it's free!</p><hr>
<label for="reg_email">What's your email address? </label><input type="email" name="email" required="" placeholder="Email" class="text" id="reg_email">
<label for="reg_password">Choose a password </label><input type="password" required="" name="pass" placeholder="Password" class="text" id="reg_password">
<label for="reg_password2">Re-type password </label><input type="password" required="" name="pass2" placeholder="Re-type password" class="text" id="reg_password2">
<input type="checkbox" name="subscribed" value="subscribed" id="subscribed"><label for="subscribed">Yes, send me email updates from NewBorn Sounds. </label>
<br>
<input type="checkbox" required="flag" name="terms" value="ticked" id="terms"><label for="terms">I agree to the terms & conditions.</label>
<center><input type="submit" name="submit_reg" value="Sign Up" class="buttonClassic"></center>
</form>
</div>
maybe you could do something like this :
if($_SERVER['REQUEST_METHOD'] == "POST"){
if (isset($_POST['submit_login'])) {
//do something
} else {
//do something else
}
}
Form action needs to be a valid url, e.g. "/login.php".
Checkboxes have either the value given (once checked), or they do not appear at all. Best is to double check them: "isset($_POST['mycheckbox']) && 'value' ==$_POST['mycheckbox']".
Show us the php you use to evaluate the form.
How this?
<input type="submit" name="submit_reg" value="Sign Up" class="buttonClassic">
<?php
if($_POST['submit'] == 'Sign Up'){
//do something
}
?>
i have created a custom popup login box. and use form settings like that
<form action="<?php bloginfo('url'); ?>/wp-login.php?redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']); ?>" method="post" autocomplete="off">
and i use input feilds like that
<input id="login_username" name="user_name" type="text" value="" class="pop-input surfix" /><span id="placeholder_user_login">Username</span>
<input id="login_password" name="user_password" type="password" value="" class="pop-input" /><span id="placeholder_user_pass">Password</span>
<input id="register" type="submit" value="Login" class="popup-login-btn" />
but it redirecting to wp-login.php except it should process the login and redirect to the pages where from user started login.
please guide me how can i fix this.
thank you all
actually the issue was with the name element of the input field.
When i check the wp-login.php page i discover the wordpress changes the name of input fields.
<input id="login_username" name="user_name"
<input id="login_password" name="user_password"
to
<input id="login_username" name="log"
<input id="login_password" name="pass"
So i just simply replace the names and all issues were sorted out.
Thank you all