WordPress.org

Ready to get started?Download WordPress

Forums

How to return to current page after form is processed (1 post)

  1. webmachine
    Member
    Posted 10 months ago #

    I have two questions. First of all, is the strategy I am planning (see below) for processing my form okay (I don't want to use a plugin, so please don't suggest this)?

    I have developed a WordPress site whose pages are based on the following structure:

    The main area of each page contains the page's content and a sidebar. The footer has four sections that are pulled into the footer as posts with a category of "footer". The footer is identical for every different page on the site.

    One of the sections in the footer is a short contact form. I have the form being processed by a separate file, process_form.php. This works, but after the processing I want to use the PHP code:
    <?php header (location: url of current page); exit; ?>
    to return the user to the page the user was on when they filled out the form.

    I figure I should start a session in the header.php where I would save the url of the page the user is on in a session variable, then pick up that session variable in the form processor to use in the
    <?php header (location: url of current page); exit; ?>

    If that is a good strategy, what code would I use in the header to pick up the url of the current page? I have tried a number of things, none of which work.

Reply

You must log in to post.

About this Topic