Solved

Making a custom form in WordPress

Posted on 2014-01-22
5
541 Views
Last Modified: 2014-01-23
Can someone please post links to learning resources that can tell me how to do the following tasks in WordPress:

1. Present an HTML form to gather a client's name and email address
2. Run the Action= script  that receives the input from the form
3. Add the name and email address to a custom data base table.

I'm an experienced PHP developer but I don't know WordPress at all and have just begun creating a child theme and a plugin.  So I'm looking for a little jump-start on some of the basic tasks.

Thanks and regards, ~Ray
0
Comment
Question by:Ray Paseur
  • 3
  • 2
5 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 500 total points
ID: 39801246
Hi Ray,

There are LOTS of ways to skin this particular cat.  The exact method you choose will largely be determined by how tightly integrated you want the data to be.  A simple collection form without further extraction on the front end is a relatively simple thing for any developer and requires a minimal knowledge of WordPress trivia.  The solutions get progressively more complicated from there...

The easiest and least WordPressy way to do this is to make a custom page template:

http://codex.wordpress.org/Page_Templates

in the theme and just add all the relevant PHP and HTML to the template and only minimally worry about the WordPress architecture and ecosystem.  

On the WordPress side, when you go to publish the page with the form, you use the Template Selector shown in the link above to choose this template.  Content is optional...you are hardcoding it anyway so all content could be in the template file or you could position the_content() above or below your hardcoded form and the page template will display the content as needed.

-----------------

The next step up in complexity is to "do it the WordPress way" and use WordPress functions to register the new table within the hierarchy which makes it visible and available to other WordPress functions. The best and most basic explanation I have found is this one:

http://wp.tutsplus.com/sessions/custom-database-tables/

It's a little below your level but it does a nice job of showing the WordPress-specific syntax used to pass MySQL queries to registered tables with $wpdb.

-------------

The most WordPress-specific way of doing this is to not use a table at all and instead register everything as custom fields.  There is a fair bit of controversy about the wisdom of this, especially on large sites so I will just mention it and leave it alone otherwise.

You can also use plugins to bypass the developer entirely, but again I sense that's not quite what you are looking to do.
0
 
LVL 109

Author Comment

by:Ray Paseur
ID: 39801583
That's great, Jason.  Thanks a ton! ~Ray
0
 
LVL 109

Author Closing Comment

by:Ray Paseur
ID: 39801585
Just what I was looking for, thanks!
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 39801589
You're welcome.  Feel free to post back here with anything you need clarification on.
0
 
LVL 109

Author Comment

by:Ray Paseur
ID: 39801874
Yeah, I know Andrew.  He's a member of the DC PHP Users Group.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WordPress Themes 10 46
how i fix Remove render-blocking JavaScript 3 80
Two wordpress questions 3 62
Change size 15 53
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question