• Hi, I am a programmer, but new to WordPress. I created a WordPress site and I want to add a php form that I created on a regular static php web page and put it in this WordPress site. Its a standard html form with a submit button that calls the php on the same page and posts the form data to a database table. how would I put this form into the body of my WordPress page? I see there are plugins like exec-PHP that I assume may be what is needed to accomplish this but I can’t find any clear documentation. thanks for any help on this.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    You could implement the form in a shortcode and then insert that on your page. That’s how most of the form plugins do it.

    https://codex.www.ads-software.com/Shortcode_API

    Thread Starter eddie777

    (@eddie777)

    So with my form code on my wordpress page:
    <form action=”mysignup.php” method=”POST”>

    instead of calling mysignup.php by putting a mysignup.php file in the wp-admin folder (or some other place accessible to wordpress) i would somehow trigger this php code somewhere using a shortcode?

    not sure how what would work. Could you give me any more detail. Thanks!

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    action='', I think.

    that should result in the current page being (re)called.

    Why are you using a bespoke form instead of using one of the many form plugins available for WordPress?

    Moderator bcworkz

    (@bcworkz)

    If you directly load a PHP file, either by request or as an action attribute, the WP environment will not be properly initialized. If you’re not using any WP functions or other resources in your PHP code, then that’s not a problem.

    If you require or include wp-load.php or wp-blog-header.php on your PHP page to initialize the environment, you are doing it wrong. While it may work on your installation, it will fail on others. There’s only 3 proper ways to initialize the environment. Contain your code within a custom page template, use AJAX, or pass requests through /wp-admin/admin-post.php.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding my custom php form to a WordPress page’ is closed to new replies.