Jump to content

Page with 2 forms not workign right


cooldude832

Recommended Posts

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

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'];
}
?>

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

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

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.