Php code to redirect using radio button

by edward2011 5 replies
Anyone can help, I am not good to Php programming. Here is my problem:

Add a Form that will allow redirection to specific URLS based upon form field content.

We will use this to direct users to the correct furnace based on content in form fields submitted.

PHASE I - FURNACE SELECTION

Create one form with these questions -

QUESTIONS:

What is the Total Square footage of the building(s)? ____

How well insulated is the space to heat? _ Very Well _ Somewhat __ Poorly

In what State? _

After they submit the form

LOGIC

IF State is IN or MA or MD or ME or NH or NY or PA or RI or VT or WA
THEN send user to GX page

IF TSQ is less than 3,500 and not poorly insulated
THEN send to GX page

IF TSQ is greater than 4000
THEN send to HE2 page

IF TSQ is less than 4000 and poorly insulated
THEN send to HE2 page

IF TSQ is less than 4000
THEN send to HE11 page


Please help me to create this. I am using wordpress.
#programming #button #code #php #radio #redirect
Avatar of Unregistered
  • Profile picture of the author prince55l
    in php after the submit form, use
    if($_REQUEST[variable.value] < 3500){

    //redirect action goes here
    }elseif($_REQUEST[variable.value] > 4000){

    //redirect action goes here

    }elseif($_REQUEST[variable.value] < 4000){

    //redirect action goes here
    }else{

    //redirect action goes here
    }

    where $_REQUEST[variable.value] is your form submitted variable
    {{ DiscussionBoard.errors[8092570].message }}
  • Profile picture of the author Brandon Tanner
    Originally Posted by edward2011 View Post

    I am good to Php programming.
    This is really basic stuff for a PHP programmer. It requires nothing more than a form and a handful of conditional statements (I would probably use switch/case for this), with a simple redirect inside each statement.

    What part don't you understand?

    PHP Tutorial - Forms

    PHP Tutorial - Switch

    If you'd just rather pay someone else to do it, then this is the wrong section for job offers. Try somewhere like Elance (as FSA suggested), or the 'Warriors for hire' section.
    Signature

    {{ DiscussionBoard.errors[8092760].message }}
    • Profile picture of the author edward2011
      Thanks for all your comment. It is very helpful to me...
      {{ DiscussionBoard.errors[8093142].message }}
    • Profile picture of the author edward2011
      Sorry, I was mistaken with my post. I am not good in programming like php language.
      {{ DiscussionBoard.errors[8093150].message }}
  • Profile picture of the author Valdor Kiebach
    It would be easiest to use 'case switch' or 'if else' to decide on the redirect.

    So on your forms selection for state you would have a selection box and use something like this in the php that handles the forms submit you could have an array holding the states that direct to GX such as
    PHP Code:
    states=Array ("IN","MA","MD"," ME"," rest of them"
    Then just check if the posted data is in the array and redirect to GX page.

    But I just noticed you are using wordpress and I try to avoid it if possible so cant say how easy it would be to integrate this into it. I would think it would just be a case of including the HTML form code on a WP page as normal and have a seperate php script to handle the form response and redirect to the WP page needed.

    So your HTML form could be something like this:
    HTML Code:
    <form name="boiler" action="whatever.php" method="post">
    What is the Total Square footage of the building(s)?<br /> 
    <input type="radio" name="size" value="small">less than 3,500<br />
    <input type="radio" name="size" value="large">greater than 3,500<br /><br />
    How well insulated is the space to heat?<br />
    <input type="radio" name="insulated" value="well">Well<br />
    <input type="radio" name="insulated" value="somewhat">Somewhat<br />
    <input type="radio" name="insulated" value="poor">Poorly<br /><br />
    In what state?<br />
    <select name="state">
    <option value="in" selected>IN</option>
    <option value="ma">MA</option>
    <option value="md">MD</option>
    <option value="xx">All the others</option>
    </select><br /><br />
    <input type="submit" value="Send">
    </form>
    Anyway this might help:
    Handling select box (drop-down list) in a PHP form
    {{ DiscussionBoard.errors[8093277].message }}
Avatar of Unregistered

Trending Topics