MyBB Community Forums

Full Version: How does mybb Check if SUBMIT button is clicked?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am having this confusion since a long time :/

I have looked into mybb codes but couldn't find anything.

I just see $mybb->input[VAR] everywhere.

The question, how does it check if the input button is clicked?

Just wanna ask since i am making a external script for mybb that is self-parsing. So if i don't check it with some code weather the submit button was clicked (like array_key_exists("submit", $_SUBMIT)) or not then it gives me error "Undefined index"

Thank you Big Grin
You could use jquery to check if a button has been clicked:

$("#YourButtonID").click(function(){
  // All your code here
});
lol no.

I want to know how MyBB does it Sad
It checks $mybb->request_method == "post", and $mybb->input['submit']. That's how forms work, the selected button is included in the submitted data. Usually it also checks action=do_something_or_other.
@frostschutz, thanks for responding, still it looks kinda unclear.
if($mybb->input['action'] == "do_drafts" && $mybb->request_method == "post")
{
	// Verify incoming POST request
	verify_post_check($mybb->input['my_post_key']);
        // ...
}
(2013-07-20, 03:57 PM)Cedric Wrote: [ -> ]still it looks kinda unclear.

If it's not clear just by reading the code, add debug messages. In particular print $mybb->input and see what it looks like when a) you preview a new post (preview button) b) you post a new post (submit button) and find the difference.