Support » Fixing WordPress » Post form PHP without plugin displays no header/footer

  • Form has action “action=’myphp.php'” referencing server side php file to post.

    The php file processes and display my result(html table) properly, however the site header and footer doesn’t appear–showing a blank page (except for my output). I would like to know best way to process a form php file via POST while preserving the header. wordpress get_header() function called from myphp.php php file errors out and php file resides under theme folder.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You could use AJAX to simply submit the form and change the content on the page, except for the header/footer, or perhaps your myphp.php file doesn’t have the footer/header functions in it.

    Moderator bcworkz


    If your PHP page uses WP resources in any way, you mustn’t submit directly to such a page at all. There are ways to make such a setup work, but it would not be compatible with other WP installations, it cannot be considered 100% portable.

    Carl’s suggestion of Ajax is one valid way to handle forms. Another is to submit through wp-admin/admin-post.php. It’s similar to Ajax in WP where you pass an “action” value which is used to construct an action tag which is then triggered, executing a callback you’ve added.

    Since you have already developed a PHP file, the simplest way to adapt it to a valid WP technique is to convert it into a custom page template. Add a new page based on the template, then have your form submit to that page’s permalink.

    Converting to a page template may be as simple as adding the proper comment header and ensuring your code calls get_header() and get_footer().

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post form PHP without plugin displays no header/footer’ is closed to new replies.