Support » Fixing WordPress » Form handling with WordPress – How to?

  • I’ve been using WordPress for quite awhile, but when I’ve needed form handling I’ve either

    o Used a form plugin that gathers the data and simply forwards it e-mail
    o Coded a form and its action page outside of the WordPress environment (and kludged the theme)

    I’d like to figure out the “right” way to do this, but am having trouble finding documentation on this.

    What I’d like to do is have

    1. Page 1 has a form that collects some information
    2. Page 2 displays that information and customizes other content based on that info

    If I use a plugin, e.g. Contact Form 7, I can see how to save the data from the first page, but I can’t figure out what token the two pages have in common so I can retrieve the data reliably in code on Page 2. Is there such a variable in WordPress that identifies the “session”?

    Or is the “right” way to code a PHP file for Page 1’s form action so that the $_REQUEST is available directly (giving up the benefits of the form plugin)?

    I’m open to suggestions — have tried cookies and global variables without success, but can revisit things if anyone can give me pointers on a “good” strategy. Or am I just not using the right plugin? [Had also tried Cforms II but was having difficulties that sent me to Contact Form 7.]


Viewing 2 replies - 1 through 2 (of 2 total)
  • Here’s the path I’m going down for now. If anyone has a better suggestion, I’d be glad to hear about it:

    Set up the $posted_data array

    setcookie ('myformdata',$myformdata,0,'/',$_SERVER['HTTP_HOST'],false,true);

    Then to retrieve the data


    The third parameter there is the expiration time of the cookie and it should obviously be something other than “0”. Sorry for copying in test code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Form handling with WordPress – How to?’ is closed to new replies.