1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Processing a button in a template with PHP

Discussion in 'XenForo Development Discussions' started by Mitchell996, Jul 28, 2013.

  1. Mitchell996

    Mitchell996 Member

    I'm trying to figure out how to process a button in a XenForo template with custom php code out of my addon script. Please direct me in towards my solution, if at all possible
    Last edited: Jul 29, 2013
  2. EasyTarget

    EasyTarget Well-Known Member

    What do you mean by button? Are you talking about form submission?
    Mitchell996 likes this.
  3. Mitchell996

    Mitchell996 Member

    Yes, a simple forum submission.
  4. Jeremy

    Jeremy Well-Known Member

    Its a simple form, you submit to a specific URL (action), and place any PHP you want to run there.
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You need to create a route so you have a location to submit the form, then you need a controller for that route to take in the input and write it out to the database. Then create the HTML form that submits to your new route location.

    That's the general idea.
    Pereira and Marcus like this.
  6. Mitchell996

    Mitchell996 Member

    I still don't understand how to do this under XenForo. I need to have a simple page, with a simple button, that updates a simple row in the user table.

    The idea is that the plugin generates a key and sets the key under a new column in the user table "gen_key".
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  8. Mitchell996

    Mitchell996 Member

    So if I place a form on that page, then I can use the callback to process it?
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  10. Mitchell996

    Mitchell996 Member

    How does the form itself come to interact with the callback?
  11. KenSmith

    KenSmith Active Member

  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    ...and of course the form action will point to the URL of the page node.

Share This Page