0

I have a HTML form that user can interact with and insert the data to a database. ( One HTML form and about 3 pages .php ) I need to implement this form to a word press page. I created a page in wordpress and it gives me a blank area to write my content but i don't know where i put my files. so appreciate your support to help me , thanks .

2
  • "and about 3 pages .php" this implies you plan to interact directly with the db which is not recommended, you should use the wpdb object or just use a plugin such as this Commented Dec 3, 2014 at 12:19
  • Thanks Andrew , yes you are right , i will interact directly with the data base , before i decide to do that , i already checked all plugin like contact form 7 , ninja form , etc , all of them doesn't fit my needs ,.....why it is not recommended to interact with db direct ?? Commented Dec 3, 2014 at 12:50

2 Answers 2

3

Where you place your files depends greatly on the structure of your wordpress template. If you want to make a page that can be accessed via a url like "www.yourdomain.com/form", then you can make a "Page" in Wordpress (via the "Page" panel via the dashboard), and name it "Form" and then, in your form's HTML (or PHP) file, set your HTML up as a template using this syntax:

Put this at the very top of your PHP page that contains your form's HTML/PHP:

<?php
/*
Template Name: My Form Page
*/

The code comment above is something wordpress will look for exclusively, and tells the wordpress engine that this page (your form HTML) is now a template named 'My Form Page'. So now, in the Wordpress Page editor for your "Form" page, you can attach your new template to your newly-created "Form" page by selecting "My Form Page" from the Template Dropdown in the Page editor.

Here is a screenshot of what the "Template Dropdown" looks like (per the Wordpress documentation):

Here is a screenshot of what the "Template Dropdown" looks like:

After you follow these steps, navigating to this page will reveal your form's HTML, instead of a blank page.

You should refer to the Wordpress documentation on Page Templates for more information:

Hope this helps!

Sign up to request clarification or add additional context in comments.

1 Comment

on more question please @radiovisual i make the page now as u said , page run successfully , but there is a problem when the form submitted , i develop the form to returned back to the same page after submit [action="mysamepage.php"] , the page is hanging after press submit and nothing displayed , it can not locate this page, what should i do ?
2

There are a few ways to add custom behaviour to a WordPress installation. Either per Addon/Plugin or Template Logic or custom modifications. I would recommend that you read through the wordpress developer guidelines and write your php files as plugin.

After that hook your plugin to your desired destinations and do your whished actions.

See this link for writing your plugin: wordpress codex

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.