#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    5
    Rep Power
    0

    Same FormMailer for many pages


    I need a FormMailer that will handle all my webpages. I want to know from which page they called the Form and have the ThankYou page send them back to that calling page. Is there any php code out there that will do this?

    Thanks,

    friend.
  2. #2
  3. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,111
    Rep Power
    1990
  4. #3
  5. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    When your form-producing page begins to load you'll need to identify the page that sent the user there. There's a few ways.

    1.
    When the user visits a page that has a link to the form, have that page's logic include its own URL location in the user's session. This can later be pulled out after the form is processed and the user can be returned to it.

    2.
    Have the sending page include a URL or an identifier that maps to a URL, as a parameter when calling the form-producing page, ala: form.php?returnURL=http://www.blah.com (with proper URL encoding)

    You'd then either store the returnURL value in the session or include it within the form as a hidden field; just some way to keep track of it as the user is filling out and submitting the form.

    3.
    You can try to capture the referrer URL HTTP variable and similarly store its value in session or a hidden field. Referrer fields can be a bit iffy, though, so I'm not sure I'd trust it.

    Then...

    You process your form and send the email. Depending on what you chose above, you'd either grab the return URL from the session or from $_POST, and redirect the user to it.

IMN logo majestic logo threadwatch logo seochat tools logo