Support » Plugin: PHP Code Widget » Creating forms using PHP Code Widget

  • Resolved Will Zachmann


    I am trying to work out how to create and use a data base driven form using the PHP Code Widget and putting it (via shortcode) into the main section of a page or post. Has anyone done this successfully? Does anyone have code examples?

    Creating the data-base driven form has been no problem for me. The part that is not so clear to me is how best to handle the form data (which I am sending back with a POST). I know how to do that in a standard PHP page entirely outside of WordPress. I am not sure, however, how (or if) that is going to work in this case. I am about to try that, but I thought I’d also ask here to see if anyone has already done that and can help steer me in the right direction.

    Any help or suggestions would be most appreciated. Thanks.

    Will (William F. Zachmann, Canopus Research Inc.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Samuel Wood (Otto)


    The PHP Code widget would be entirely inappropriate for this sort of usage. If you need to make shortcodes or put things in the main body of the post, then write a normal plugin. Don’t use this widget.

    Otto, why is that (i.e. why would it be “entirely inappropriate”)? I actually seem to have got it working (so far, at least) by simply dropping my PHP code into an instance of your PHP Code Widget which I have placed inside one of the “Ad Hoc Widget” areas of Sayonton Sinha’s Suffusion theme (which “ad hoc” widget areas can then be placed anywhere, including in pages and posts, using a shortcode).

    Now I have not yet included code to read the GET or PUT parameter (or session) data, but so far it looks like I will probably be able to do that. Is there something I am missing here? Some security or other hazard I am overlooking?




    Can you tell me more about how you created the shortcodes and if adhoc widgets are supported in all WP templates?

    I’m using the responsive template from theme id

    Anubhav, what I have done in this case is to combine the use of Otto’s PHP Code Widget with a feature specific to Sayonton Sinha’s Suffusion theme – his “Ad Hoc Widget” areas by 1) writing my PHP code and putting it in one of Otto’s PHP Code Widget’s; 2) dropping that into one Sayonton’s Ad Hoc Widgets; and then 3) dropping the short code for Sayonton’s Ad Hog Widget that has Otto’s widget in it into the contents of a page.

    This does have somewhat the aspect of “counting a herd of sheep by counting their legs and dividing by four” to it, but it actually works just fine. To be sure, a cleaner approach would just be to write custom pages with the custom PHP code in place of the normal ‘loop’ and I likely will re-factor this site that way eventually. There may be some other gotchya’s lurking in it as well though I haven’t stumbled across any thus far.

    You might look at the code in Sayonton’s theme that implements his “Ad Hoc Widget”. I expect that could be adapted fairly easily to some other theme, but I just have not had time to get around to examining it yet. So much to do, so little time! *;-)

    All the best,


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Creating forms using PHP Code Widget’ is closed to new replies.