Solved: 10 Months, 1 Week ago ACP > Legalize POST button
#1
Solved: 10 Months, 1 Week ago
I'm a beginner and need some help for a problem which seems to be a small one for you and which seems to be an unsolvable task for me.

I have defined a button in a PlugIn with which I delete a file. The button is displayed correctly.

This is how the code in the PlugIn looks like:

$form_container = new FormContainer();
 $form_container->output_row("<form action=\"\" method=\"post\">
<input type=\"submit\" name=\"delete_file\" value=\"$lang->_delete_1\"/> $lang->delete_2
</form>", "", "");
$form_container->end();
if(isset($_POST["delete_file"])) {
unlink(MYBB_ROOT . "/"filename);
} 
If I click on the button, the desired function is executed correctly!

However, the message appears:
Quote:The authorization code could not be confirmed. Please confirm that you want to perform this action.
Currently I hide the error message after the "unlink" with a META Refresh, but this should certainly not be the wisdom last resort.

How to legalize the operation ($_POST) in the PlugIn so that the error message does not appear?

Thank you for any help in advance.
Reply
#2
Solved: 10 Months, 1 Week ago
Add in your form:
<input type=\"hidden\" name=\"my_post_key\" value=\"{\$mybb->post_code}\" />
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM or Discord
Reply
#3
Solved: 10 Months, 1 Week ago
Thanks, it works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)