Auto complete won't turn off? HTML Textbox/ Password fields - php

I'm trying to make it so the forms on my login/ registration pages won't preload data already entered. I've tried using autocomplete although some research on here tells me that this is ignored by Chrome? So I was wondering how else I can get around this issue?
Code:
<h3>USERNAME:</h3>
<input type='textbox' autocomplete='off' name='usernamereg' value='<?php echo $_POST['usernamereg'] ?>'>
I want the bottom 2 fields to not have the pre-entered information:
Screenshot
Any help appreciated!

For some weird reason, Google Chrome seems to ignore autocomplete rules in forms. Google Chrome also seems to only autofill the first occurrence of a username/password field. Try the following for the password field:
<input type="text" style="display:none!important">
<input type="text" autocomplete="null" name="usernamereg" value="<?php echo $_POST['usernamereg'] ?>">
<input type="password" style="display:none!important">
<input type="password" autocomplete="null" name="whatevername" value="<?php echo $yourvariable ?>">

You have saved username and password in you browser. So It fill fetch from the browser autocomplete. If you clear cache and saved password. It wont come... I face this same issue... After clearing those things. It works fine... Hope it work for you too...

write autocomplete="off" in your form tag
<form method="" action="" autocomplete="off" >
</form>
Hope this will work

Related

Php: $_POST is not set after form is sent to iframe

I have just spent 4 hours researching and nothing has fixed my problem, so here I am. I am trying to design my own little chunk file uploader, and all is working quite well.
I have a main upload page that lets you set a file to upload. It then automatically cuts the first chunk out of the bytes of the file, and puts it into a form, along with some other bits of information:
<form id="hiddenform" name="hiddenform" action="SecretChunkUploader.php" target="iframe" enctype="multipart/form-data" method="post">
<hidden id="Bytes" name="Bytes" value="" />
<hidden id="Pass" name="Pass" value="<?php echo $_POST['Pass'];?>" />
<hidden id="FileName" name="FileName" value="" />
<hidden id="PackageNumber" name="PackageNumber" value="" />
</form>
Every <hidden> has its value correctly sent when the form is submitted through this javascript command:
document.forms["hiddenform"].submit();
The form is submitted to an iframe:
<iframe id="iframe" name="iframe" onload="" style="display:block"></iframe>
When submitted, the iframe navigates to the page specified in the form's action attribute.
Everything works well, except for when the form is received. The page loads, but there is no post data, and the variables for post are not set.
Here is the code for SecretChunkUploader.php:
<?php
echo "Password: ".$_POST["Pass"]."<br/>";
echo "FileName: ".$_POST["FileName"]."<br/>";
echo "PackageNumber: ".$_POST["PackageNumber"]."<br/>";
echo "Bytes: ".$_POST["Bytes"];
?>
The loaded page from SecretChunkUploader.php looks like:
Password:
FileName:
PackageNumber:
Bytes:
I have tried testing isset() and it returned false for all of the post variables.
What on Earth am I doing wrong? I have tested and know that the form is fully working, it just doesn't pass the values onwards.
Thanks in advance for any help!
Instead of:
<hidden id="Bytes" name="Bytes" value="" />
Try:
<input type="hidden" id="Bytes" name="Bytes" value="" />
Same for all the others, of course.

Problems with slash symbol

I created form, when i submit it, i made that it just go to the same form page. When i changed value of variable( to the m=files&a=addedit) it keeps creating new one / symbol. Here is the code, and bellow the code there is the link to the picture.
$referrer = "m=files&a=addedit";
?>
<form name="uploadFrm" action="?m=files" enctype="multipart/form-data" method="post">
<input type="hidden" name="redirect" value="<?php echo $referrer; ?>" />
http://i.stack.imgur.com/CFmXo.jpg
What should i do to fix this from / creation.
Using full path (with http) should fix this issue. Try change the action attribute to:
action="http://www.your-domain.com?m=files"
It's pretty unusual to want to put a ? in the URL in a form action attribute. I'm not sure why you're doing that.
I'd suggest replacing it with a hidden field for m:
<form name="uploadFrm" action="." enctype="multipart/form-data" method="post">
<input type="hidden" name="m" value="files" />
<input type="hidden" name="redirect" value="<?php echo $referrer; ?>" />
Try that, and let us know if it works.
If you still have problems, then it's likely that the issue is actually somewhere else, not in the HTML form code you've given.
Possible places you should look:
A badly configured mod_rewrite can be prone to doing this kind of thing.
The input field on the form is called redirect; maybe the problem is happening when you do the redirect?

How to remove cache data on page reload?

I have a registration form. If a user fill out all the required fields.
And when he reloads the page with out submitting form, the fields contain the values entered by the user. I want them to be empty as they were on first page load.
I have given value="" to the fields but they still contain the previously entered values.
<form id="registration_form" name="registration_form" method="post">
<input name="first_name" id="first_name" value="">
<input name="last_name" id="last_name" value="">
<input name="user_email" id="user_email" value="">
<input name="status" id="status" type="hidden" value="active">
</form>
This is form auto-fill, not page caching. You can disable autocomplete with:
<form id="registration_form" name="registration_form" method="post" autocomplete="off">
Remember to add autocomplete="off" to your form. This is auto-complete issue with some browsers, then you need to use id trick, every time you're loading the registration page, let say:
http://localhost/register.php
you can try it manually to see if it's works for browsers you've been testing, for example load this address on your browser and see if it still auto complete the form:
http://localhost/register.php?id=23
you can add id=anynumber, this happens to work perfectly, I do this with my CSS imports. To make it more PHP you can write some code like this:
$number = rand(1,100);
header("Location: register.php?id=$number");
Hope it helps
If you want to remove cache as you asked first (before edit), There are many ways,
Adding meta tag on page
<meta http-equiv="Cache-control" content="no-cache">
By redirecting using javascript,
window.location.href+'?eraseCache=true';
These are discussed in an other topic here.
If you just want to delete the values on the fields,
use
document.getElementById('text_box_id').value="";
on the top inside the head tag.

Irregular PHP Post in Wordpress Plugin

I have a very strange strange problem in my form submissions in a plugin I'm developing.
Both take URL's as a parameter, but in one of them, I can submit www.example.com and in the other, o cannot submit the exact same link.
As result, when I try to submit, I get the following error:
You don't have permission to access /wp-admin/admin.php on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
What could this be?
This is really freaking me out.
if(isset($_POST['indot_under_submit'])){
//do stuff
}
<form name='slug_settings_form' id='slug_settings_form' method='post' action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<label for="slug_social_googleplus">Google Plus</label>
<input type="text" name="slug_social_googleplus" value="<?php echo $option['social']['googleplus']; ?>" size="60"/>
<label for="slug_social_tumblr">Tumblr</label>
<input type="text" name="slug_social_tumblr" value="<?php echo $option['social']['tumblr']; ?>" size="60"/>
<input type="submit" class='button-primary' name="slug_under_submit" id="slug_under_submit" value="Save" />
</form>
I've tried to see if it was a permlinks problem, it is not.
I tried to see if it was some kind of post limit, and it is not.
I've also tried allot of different things I cannot recall, and searched allot.
This error does not make sense to me.
What is this for site options or user settings?
If it is for site options it should be submitted to the admin options.php

Backslash at the end of searchword breaks custom search form

Accidentally, I discovered that whenever there is a backslash at the end of a search, the page after clicking submit will return a broken search form.
In my case, the submit button turned into a text area.
Using Google Chrome's "inspect element" I saw that my search form turned into this:
<form method="get" action="">
<input type="hidden" name="type" value="books">
<input type="text" name="search" value="\"> <input type=">
</form>
</div></div></div><div id=" sidebar"="" class="sidebar widget-area"></form>
The following code is my form. I am guessing that I need to sanitize/escape the value from the input type text? But why isn't esc_attr() working?
<form action="" method="get">
<input type="text" name="search" value="<?php echo esc_attr(stripslashes($_GET['search'])); ?>">
<input type="submit" value="Search">
<input type="checkbox" name="title">
</form>
P.S. I am using this custom search form to search custom fields and display the resulting custom post types using Pods Plugin. It doesn't appear that this is a Pods plugin issue though.
https://github.com/pods-framework/pods/issues/1620
Also, this doesn't appear to be a conflict from another theme or plugin.
I've made some test, I'm guessing that your question was missunderstood, this code should work:
<form action="" method="get">
<input type="text" name="search" value="<?php echo urldecode($_GET['search']); ?>">
<input type="submit" value="Search">
<input type="checkbox" name="title">
</form>
You can check the php urldecode function for extra info.
Decoding an url is the oposite of encoding it, when a special character is submited it needs to be encoded, when you want to display it you'll have to decode it.
EDIT:
After the form is submitted, when its values are processed, then you have to use esc_attr(stripslashes($_GET['search'])) so that the value becomes encoded and sql-injections and other format issues are avoided, again this has to happen in the php file where the form is processed, usually after an if ($_GET) statement.
I have tried dozens of sanitation and escaping. But in the end, only preg_replace worked against that annoying backslash.

Categories