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

How to post something to database from admin area

Discussion in 'XenForo Development Discussions' started by xpl0iter, Oct 20, 2012.

  1. xpl0iter

    xpl0iter Active Member

    I would like to create an addon which will be able to post something to database from the admin area.
    I have the db query, but don't have any idea how I could achieve this! I have a text area and a submit button, but when I submit the data, it gives me a security error. Can somebody please help me?
  2. Lawrence

    Lawrence Well-Known Member

    It seems like you are missing the token. If you use the xen:submitunit it ads the token automatically for you, for example:

        <xen:submitunit save="{xen:phrase iwdrp_save_roster}">
            <xen:if is="{$roster.roster_id}"><a href="{xen:adminlink 'iwdrp-roster/delete', $roster}" class="button OverlayTrigger">{xen:phrase iwdrp_delete_roster}...</a></xen:if>
    Will generate this:

    <input type="submit" value="Save Roster" class="button primary" accesskey="s" />
            <a href="admin.php?iwdrp-roster/staff.2/delete" class="button OverlayTrigger">Delete Roster...</a>
    <input type="hidden" name="_xfToken" value="your_token_value_goes_here_automatically" />
  3. xpl0iter

    xpl0iter Active Member

    Ok Thanks, I will try with this and let you know! :)
  4. xpl0iter

    xpl0iter Active Member

    <textarea name="foo_bar" rows="4" cols="50">
    </textarea><br />
    <xen:submitunit save="Submit">
    <a href="{xen:adminlink 'foobar/write', 1}" class="button OverlayTrigger">Submit</a></xen:if>
    </xen:submitunit><br />
    This is giving me 2 submit buttons., in which one is not working! :(

Share This Page