Multi-redirect form using PHP and form values. I am lost -
what trying work when user fills out form if choose 1 of services in drop-down home radio button , entering correct san diego zip code takes them page in drop-down. if don't enter correct san diego zip code automatically redirects them nationwide page. issue having radio buttons. need happen when user selects drop-down list , chooses office radio button redirects them office version whatever drop-down was. have enter correct sd zip here or sent nationwide page. need getting redirect correctly, thought had current code have redirected home drop-down selections, if office radio button 1 selected. can please please me out super lost right , can't think of why not working. thanks
form:
<div class="home-form"> <form method='get' id='gform_1' action='http://50.22.79.62/~pftech/form-handler/'> <div class="serviceinput" <label for="services">services: </label> <select id="selection" name="selection"> <option value='-1'>select service</option> <option value="0">water delivery</option> <option value="1">coffee services</option> <option value="2">water filtration</option> </select> </div> <div class="zipcode"> <label for="zip">zip code: </label> <input name="zip" type="text" maxlength="5" id="zip" /> </div> <div class="frontradio"> <input name="home" type="radio" id="homeradio" /> <div class="homelabel"> <label for="homeradio">home</label> </div> <input name="home" type="radio" id="officeradio" /> <label for="officeradio">office</label> </div> <div class="homebutton"> <input type='submit' id="submithome" name="did_submit" value="get started!"> </div> </form> </div>
form handler:
<?php /** * template name: form handler */ ?> <?php if(isset($_get['zip'])){ $sandiego = array('91911', '91914', '91915', '91932', '91942', '91945', '91950', '92014', '92025', '92027', '92029', '92037', '92064', '92065', '92067', '92071', '92075', '92101', '92102', '92103', '92104', '92105', '92106', '92107', '92108', '92109', '92110', '92111', '92113', '92114', '92115', '92116', '92117', '92118', '92119', '92120', '92121', '92122', '92123', '92124', '92126', '92127', '92128', '92129', '92130', '92131', '92132', '92134', '92135', '92139', '92140', '92145', '92147', '92154', '92173', '92562', '92563', '92590', '92591', '92592', '92596'); if (in_array($_get['zip'], $sandiego)){ $urls = array(); if($_get["home"] == 1) { $urls[] = "http://50.22.79.62/~pftech/office-delivery/"; $urls[] = "http://50.22.79.62/~pftech/office-delivery/"; $urls[] = "http://50.22.79.62/~pftech/office-delivery/"; } else { $urls[] = "http://50.22.79.62/~pftech/water-delivery-service/"; $urls[] = "http://50.22.79.62/~pftech/coffee-delivery/"; $urls[] = "http://50.22.79.62/~pftech/water-filtration-systems/"; } if($_get['selection'] < 3 && $_get['selection'] >= 0) { $url = $urls[$_get['selection']]; header("location: $url?zip=$_get[zip]"); } else header("location: http://50.22.79.62/~pftech/nationwide/"); } else { header("location: http://50.22.79.62/~pftech/nationwide/"); } } exit; ?>
from html form:
<input name="home" type="radio" id="homeradio" /> ... <input name="home" type="radio" id="officeradio" />
your radio buttons don't have value attribute. try like:
<input name="home" type="radio" value="homeradio" /> ... <input name="home" type="radio" value="officeradio" />
then in php:
if($_get["home"] == "homeradio") { // home urls here $urls[] = "http://50.22.79.62/~pftech/office-delivery/"; $urls[] = "http://50.22.79.62/~pftech/office-delivery/"; $urls[] = "http://50.22.79.62/~pftech/office-delivery/"; } elseif($_get["home"] == "officeradio") { // office urls here $urls[] = "http://50.22.79.62/~pftech/water-delivery-service/"; $urls[] = "http://50.22.79.62/~pftech/coffee-delivery/"; $urls[] = "http://50.22.79.62/~pftech/water-filtration-systems/"; } else { // other options can go here }
Comments
Post a Comment