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

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.