Jump to content

redirect the target page in wordpress


borzoid

Recommended Posts

I need to create a form that will pass information to different pages based on the value of the item selected in one of the dropdown boxes.

 

The form will have two fields the first is to select the state from a dropdown. The second field is to select the type of insurance they are searching for (home,auto, life, health). There will be a separate search and information page for each of these types of insurance.  So if they select "auto" the action will be auto.php and if they select "health" the action will be health.php.  This will be put inside a wordpress site (php) and will be directing to various wordpress pages.

 

It was suggested that I put a redirect in the target page.  to put the following in the "page that receives the submission"

 

<?php

$targ = $_POST['option'];

switch ($targ) {

    case "auto":

        // redirect to auto page

        break;

    case "home":

        // redirect to home page

        break;

    case "life":

        // redirect to life page

        break;

    case "health":

        // redirect to health page

        break;

    }

?>

 

Well wordpress pages are build dynamically and all use the same header.  So do I put this in the header code?  Also how is the "action" part of the form written to pass this properly.  Last question:  will it interfere with other functions in wordpress

Link to comment
https://forums.phpfreaks.com/topic/185725-redirect-the-target-page-in-wordpress/
Share on other sites

Well with php you can use the header(); function.

 

header("Location: http://www.google.com");  (or a relative URL)

 

 

The MOST important part about a header redirect, is make sure that it is happening before ANY text is echo'd to the screen.  If text is already echoed, then it will throw up an error. 

 

It shouldn't mess with any of your functions - should work like a charm

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.