Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Making a custom form in WordPress

Posted on 2014-01-22
5
Medium Priority
?
557 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 2000 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 111

Author Comment

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

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 111

Author Comment

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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Read about how to approach blogging and about ways to do it right. Stand out from the crowd and let your knowledge be consumed by a large audience. This article aims to explain how your blog should look like,  the most important things to do while b…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
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…
Suggested Courses

886 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