Irregular PHP Post in Wordpress Plugin - php

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

Related

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

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

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?

Automatically log in on another website at the click of a button - cURL or Javascript?

I would like to make a button on my website that automatically logs me in on another website. I recon I can use either Javascript/jQuery or PHP/cURL to do this.
Which is the best way to go?
You may use either remote javascript or iFrame. Find more details here: http://kuza55.blogspot.com/2007/06/building-secure-single-sign-on-systems.html
Also checkout google's approach named SAML: http://code.google.com/googleapps/domain/sso/saml_reference_implementation.html
It depends what the website is. JavaScript and jQuery alone cannot be used due to the cross-domain policy. You could perhaps use a combination of cURL and AJAX to achieve something similar.
I think you might need to provide a little more information about the site, and exactly why you'd want to do this...
I'm not sure if this is exactly what you're looking for, but one thing I have done in the past is to mimic the login form on the site you want to log in to.
For example lets say you want to log in to 'example.com'. In the source code for the login page of 'example.com' you will find the html code for the login form.
Example
<form name="blabla" action="action.php" method="post">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="sumbit" value="Login" />
</form>
Create a form on your site similar to the one you find in 'example.com'. If you want you can even hide the fields, include values to make it a one button login. The trick is making sure that the action has the actual url. For example if the form says 'action.php' for 'example.com' you would put 'http://example.com/action.php'
Example
<form name="blabla" action="http://example.com/action.php" method="post">
<input type="hidden" name="username" value="testuser" />
<input type="hidden" name="password" value="testpass" />
<input type="sumbit" value="Login" />
<form>
This will log you in to the site in most cases. If you don't want to leave your own site you can set a 'target' for the form to an iframe or something.

PHP Script won't load

I'm new to web development and have been wrestling with this problem for several hours now, so I've decided to turn to your wisdom. I'm trying to design a little webpage with a database for my wife to store her recipes in, but I'm having trouble getting form submission to work. Here is the code for the webpage where I take the form information in:
<html><body>
Enter the information below to add a new ingredient for use in your recipes.
<form action="add_to_database.php" method="post">
Name: <input name="name" type="text" />
Serving: <input type="text" name="serving" />
Calories: <input type="text" name="calories" />
<input type="submit" />
</form>
</body></html>
And here is some silly code I've been trying to display on the page to see if I can even get the form submission to work:
<html><body>
<?php
$name = $_POST['name'];
echo $name."<br />";
?>
</body></html>
Unfortunately, the page comes back as completely back (after I hit the submit button). What's absolutely baffling to me is that I've copied and pasted the examples from this page into some files and everything seems to work fine. So it seems as though apache and php are working correctly, but I'm messing up somewhere along the way. My apologies in advance if this seems like a stupid question but for the life of me I can't figure it out.
Do you name the other file as add_to_database.php where the form is submitted. Instead you can test on teh same page by removing the add_to_database.php from the form action.
form action="" method="post">
Name: <input name="name" type="text" />
Serving: <input type="text" name="serving" />
Calories: <input type="text" name="calories" />
<input type="submit" />
</form>
and write the php code on the same page as
$name = $_POST['name'];
echo $name;
If this is not working for you. Create a php file named test.php and type phpinfo(); there.
Verify that your page is indeed being processed by PHP - obvious question, but does your PHP file have a .php extension? Do other things like phpinfo() or echo "Test"; work?
Check the error log in /var/log/apache2/error.log or similar (if on Linux, dunno where that'd be on Windows).
Try turning display_errors on in the PHP configuration (this is a good idea only for a development install, not a production server).
a bit of a longshot, but if you can verify that php is pro essing the page. Clean up your html, you are missing the dtd, head, and encoding. . hard to say how a browser is going to interpret a form (missing a name attribute) without these.

Categories