Title: Creating forms using PHP Code Widget
Last modified: August 20, 2016

---

# Creating forms using PHP Code Widget

 *  Resolved [Will Zachmann](https://wordpress.org/support/users/canopusresearch/)
 * (@canopusresearch)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/creating-forms-using-php-code-widget/)
 * 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. [wfz@canopusresearch.com](https://wordpress.org/support/topic/creating-forms-using-php-code-widget/wfz@canopusresearch.com?output_format=md))
 * [http://wordpress.org/extend/plugins/php-code-widget/](http://wordpress.org/extend/plugins/php-code-widget/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [13 years, 6 months ago](https://wordpress.org/support/topic/creating-forms-using-php-code-widget/#post-3102497)
 * 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.
 *  Thread Starter [Will Zachmann](https://wordpress.org/support/users/canopusresearch/)
 * (@canopusresearch)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/creating-forms-using-php-code-widget/#post-3102530)
 * 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?
 * Thanks!
 * will
 *  [anubhav_r](https://wordpress.org/support/users/anubhav_r/)
 * (@anubhav_r)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/creating-forms-using-php-code-widget/#post-3102623)
 * Will.
 * 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
 *  Thread Starter [Will Zachmann](https://wordpress.org/support/users/canopusresearch/)
 * (@canopusresearch)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/creating-forms-using-php-code-widget/#post-3102624)
 * 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,
 * will

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Creating forms using PHP Code Widget’ is closed to new replies.

 * ![](https://ps.w.org/php-code-widget/assets/icon.svg?rev=992095)
 * [PHP Code Widget](https://wordpress.org/plugins/php-code-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/php-code-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/php-code-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/php-code-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/php-code-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/php-code-widget/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [Will Zachmann](https://wordpress.org/support/users/canopusresearch/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/creating-forms-using-php-code-widget/#post-3102624)
 * Status: resolved