• Starting out, I created a couple bear-bones Page templates. One served as a form (several lines of text input) and the other template pulls that data in order to echo it and populate the page. In WordPress, I created 2 pages, each one using one of the templates i created, and they work fine.

    Now, I want to do this same thing in posts (for easier addition of new) but it doesn’t work. Is PHP crippled in posts?

    The form is showing up fine in Post1, and the data is being sent to Post2 properly (it shows up in the url: post2?data1=X1&data2=Y… etc.) but the data isn’t being populated into the post itself.

    This is the code I’m using to pull and display the form data:

    <?php $word1 = $_GET['word1']; echo htmlspecialchars($word1, ENT_QUOTES, 'UTF-8'); ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • PHP cannot be entered in Posts or Pages, though you can overcome that problem for Pages by coding PHP in the Page’s Template. It was a conscious decision by WordPress to avoid security issues.

    There are PHP plug-ins. I chose to build my own “infrastructure” using Custom Fields, though I don’t use Posts, only Pages.

    There is some discussion of this (why no PHP and the plug-ins) in the Codex.

    Thread Starter mathechr

    (@mathechr)

    Thanks for the info.

    I installed the Exec-PHP plugin, and it works like a dream.

    /cheers

    Just the usual warning: be sure that only people you trust can insert PHP into a Post. Or you’ll open yourself up for Hackers.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Displaying form data in a post’ is closed to new replies.