cooldude832 Posted July 17, 2007 Share Posted July 17, 2007 I have a page that lets me change some search criteria to different types. You can see it at http://www.americandreamhorses.com/search.php It works great if you change the criteria type ( its a form separate from search), but if you submit the search form all the criteria dissapears. Anyone got any ideas. This is what i'm trying right now. <?php session_start(); if(!empty($_GET['adcrt'])){ $_SESSION['adcrt'] = $_GET['adcrt']; } if(empty($_SESSION['adcrt'])){ $_SESSION['adcrt'] = "horse"; } //then the echo part is a switch switch ($_SESSION['adcrt']){ case "horse": echo $search['horse']; break; case "pet": echo $search['pet']; break; case "trailer": echo $search['trailer']; break; case "tack": echo $search['tack']; break; case "apparel": echo $search['apparel']; break; case "saddle": echo $search['saddle']; break; default: echo $search['horse']; } ?> Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/ Share on other sites More sharing options...
cooldude832 Posted July 17, 2007 Author Share Posted July 17, 2007 and whats strange is I can get it to echo out $_SESSION['adctr'] and it looks right but not echo out $searchcritera[$_SESSION['adctr']] (using the switch I made) Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/#findComment-300679 Share on other sites More sharing options...
teng84 Posted July 17, 2007 Share Posted July 17, 2007 dude try this <?php session_start(); if(isset($_SESSION['adcrt'])){ $_SESSION['adcrt'] = "horse"; } //then the echo part is a switch switch ($_SESSION['adcrt']){ case "horse": echo $search['horse']; break; case "pet": echo $search['pet']; break; case "trailer": echo $search['trailer']; break; case "tack": echo $search['tack']; break; case "apparel": echo $search['apparel']; break; case "saddle": echo $search['saddle']; break; default: echo $search['horse']; } ?> <?php //better session_start(); if(isset($_SESSION['adcrt'])){ echo $search[$_SESSION['adcrt']]; } else{ echo $search['horse']; } ?> Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/#findComment-300687 Share on other sites More sharing options...
cooldude832 Posted July 17, 2007 Author Share Posted July 17, 2007 that ain't gonna work, because it doesn't set the session, my issue isn't that for some stupid reason it won't echo out the variables $search['pet'] or $search['trailer'], etc etc if that second form is submitted even though it will echo out $_SESSION['adctr'] as you can see with: <?php <?php require('includes/search_critera.php'); switch ($_SESSION['adcrt']){ case "horse": echo $search['horse']; echo $_SESSION['adcrt']; break; case "pet": echo $search['pet']; echo $_SESSION['adcrt']; break; case "trailer": echo $search['trailer']; echo $_SESSION['adcrt']; break; case "tack": echo $search['tack']; echo $_SESSION['adcrt']; break; case "apparel": echo $search['apparel']; echo $_SESSION['adcrt']; break; case "saddle": echo $search['saddle']; echo $_SESSION['adcrt']; break; default: echo $search['horse']; echo $_SESSION['adcrt']; } ?> Its getting me really mad cause it doesn't make sense Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/#findComment-300692 Share on other sites More sharing options...
teng84 Posted July 17, 2007 Share Posted July 17, 2007 dude check echo $search['horse']; echo $_SESSION['adcrt']; can i see this array $search and the setting of this $_SESSION['adcrt']=??? maybe no echo because no value at all Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/#findComment-300700 Share on other sites More sharing options...
cooldude832 Posted July 17, 2007 Author Share Posted July 17, 2007 it works fine in one case and not another the array is huge. Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/#findComment-300704 Share on other sites More sharing options...
teng84 Posted July 17, 2007 Share Posted July 17, 2007 it works fine? where in the case of horse? if that so then the session array if the prob Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/#findComment-300709 Share on other sites More sharing options...
cooldude832 Posted July 17, 2007 Author Share Posted July 17, 2007 i think i've got it worked out now, I'm using includes I think my issue was that when the other form was set I had a var called $search in the doc thus it deleted my array but its good now. I hate stupid issues like that Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/#findComment-300711 Share on other sites More sharing options...
teng84 Posted July 17, 2007 Share Posted July 17, 2007 dude tip if u think u have the error on some array always use print_r() or var dump it helps me fast to debug Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/#findComment-300713 Share on other sites More sharing options...
cooldude832 Posted July 17, 2007 Author Share Posted July 17, 2007 Do i have to declare session_start(); pre the doc type for sessions to register? Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/#findComment-300739 Share on other sites More sharing options...
teng84 Posted July 17, 2007 Share Posted July 17, 2007 Do i have to declare session_start(); pre the doc type for sessions to register? what? Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/#findComment-300750 Share on other sites More sharing options...
cooldude832 Posted July 17, 2007 Author Share Posted July 17, 2007 do i have to have <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> or can i have <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php session_start(); ?> Version B failed and Version A works, But Version A is not xhtml 1.6 stricness Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/#findComment-300751 Share on other sites More sharing options...
teng84 Posted July 17, 2007 Share Posted July 17, 2007 i dont think it affect that version thing your talking Link to comment https://forums.phpfreaks.com/topic/60446-page-with-2-forms-not-workign-right/#findComment-300755 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.