I have a vehicle form where people select a year and it updates the make box and then they select make and so on. My issue is that it submits to a file which searches a database and sends the user to a page in my shopping cart. I need to pass the variables of the form to the shopping cart. I do not want to send the variables along with the address. I know there is a way to do it but I am lost. I have tried many ways but I cant seem to make it work. Any suggestions would be greatly appreciated.
This is the code on the page the form submits to.
<?php
include 'dbinfo.php';
$link = mysql_connect($servername,$user,$pass);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db($db);
function setyear()
{
global $table;
$make='';
$query = "SELECT acura from $table where year=".$_REQUEST['year'];
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
$make = $make.$row["acura"].'|';
}
echo $make;die();
}
function allyear()
{
global $table;
$make='';
$query = "SELECT year from $table ORDER BY year";
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
$make = $make.$row["year"].'|';
}
echo $make;die();
}
function setmake(){
global $table;
$query = "SELECT model from $table where year="."'".$_POST['year']."'"."and acura="."'".$_POST['make']."'";
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
$model= $row["model"].'|';
}
echo $model;die();
}
function setmodel()
{
global $table;
$query = "SELECT cylinder from $table where year=".
"'".$_POST['year']."'"." and acura="."'".$_POST['make']."'". " and model="."'".$_POST['model']."'";
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
$model=$row['cylinder'].'|';
}
echo $model;die();
}
function gourl(){
global $table;
$query = "SELECT link from $table where year=".
"'".$_POST['year']."'"." and acura="."'".$_POST['make']."'". " and model="."'".$_POST['model']."'"
. " and cylinder="."'".$_POST['engine']."'";;
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
$row = mysql_fetch_assoc($result);
$link = $row['link'];
return $link;
}
if (array_key_exists('option',$_GET)) {
if ($_GET['option'] == 'setyear')
{
setyear();
}
if ($_GET['option'] == 'setmake')
{
setmake();
}
if ($_GET['option'] == 'setmodel')
{
setmodel();
}
if ($_GET['option'] == 'allyear')
{
allyear();
}
}
if (array_key_exists('go',$_POST)) {
if ($_POST['go']=="SendQuery")
{
$link = gourl();
header("Location:$link");
die();
}
}
?>