I'm trying to decode a variable the user inputs into two different things, depending on the input.
Here it is in context:
User inputs 591P1001; 59 is the year, 1 is the series, P is the assembly plant and 1001 is the CUN.
Now on the same page, if the user inputs 814P1001, the information is decode as 8 is the engine, 1 is the series, 4 is the year, P is the assembly plant and 1001 is the CUN.
How can I use the same variable I've defined as $decode=trim($_POST) to display different things based on the input. Right now it works fine for the first example but displays nothing when the second example is input.
Here is my code:
<?php
$decode=trim($_POST['VIN']);
// 1959 - 1963 Pontiac Begins
$ModelYear=substr($decode,1,2);
if ($ModelYear >= 59 && $ModelYear <= 63){{
echo "";
}
$Series=substr($decode,0,1);
$ModelYear=substr($decode,1,2);
if ($Series == "1" && ($ModelYear >= 59 && $ModelYear <= 60)){
echo "$Series = Catalina<br />";
} elseif ($Series == "1" && ($ModelYear >= 61 && $ModelYear <= 63)){
echo "$Series = Tempest<br />";
} elseif ($Series == "2" && $ModelYear == "63"){
echo "$Series = Lemans<br />";
} elseif ($Series == "3" && $ModelYear == "60"){
echo "$Series = Ventura<br />";
} elseif ($Series == "3" && ($ModelYear >= 61 && $ModelYear <= 63)){
echo "$Series = Catalina<br />";
} elseif ($Series == "4" && ($ModelYear >= 59 && $ModelYear <= 60)){
echo "$Series = Star Chief<br />";
} elseif ($Series == "5" && $ModelYear == "61"){
echo "$Series = Ventura<br />";
} elseif ($Series == "6" && ($ModelYear >= 61 && $ModelYear <= 63)){
echo "$Series = Star Chief<br />";
} elseif ($Series == "7" && ($ModelYear >= 59 && $ModelYear <= 62)){
echo "$Series = Bonneville Safari<br />";
} elseif ($Series == "8" && ($ModelYear >= 59 && $ModelYear <= 63)){
echo "$Series = Bonneville<br />";
} elseif ($Series == "9" && ($ModelYear >= 62 && $ModelYear <= 63)){
echo "$Series = Grand Prix<br />";
} else {
echo "Pontiac didn't offer this series in 19$ModelYear. Please check your VIN and try again.<br />";
}
$ModelYear=substr($decode,1,2);
if ($ModelYear >= 59 && $ModelYear <= 63){
echo "$ModelYear = 19$ModelYear<br />";
} else {
echo "Invalid model year. Please check your VIN and try again.<br />";
}
$AssemblyPlant=strtoupper(substr($decode,3,1));
if ($AssemblyPlant == "A" && $ModelYear == "59"){
echo "$AssemblyPlant = Atlanta, GA<br />";
} elseif ($AssemblyPlant == "A" && ($ModelYear >= 60 && $ModelYear <= 63)){
echo "$AssemblyPlant = Arlington, TX<br />";
} elseif ($AssemblyPlant == "C" && $ModelYear == "59"){
echo "$AssemblyPlant = Southgate, CA<br />";
} elseif ($AssemblyPlant == "D" && ($ModelYear >= 60 && $ModelYear <= 63)){
echo "$AssemblyPlant = Doraville, GA<br />";
} elseif ($AssemblyPlant == "E" && ($ModelYear >= 60 && $ModelYear <= 61)){
echo "$AssemblyPlant = Euclid, OH<br />";
} elseif ($AssemblyPlant == "F" && $ModelYear == "59"){
echo "$AssemblyPlant = Framingham, MA<br />";
} elseif ($AssemblyPlant == "K" && ($ModelYear >= 59 && $ModelYear <= 63)){
echo "$AssemblyPlant = Kansas City, KS<br />";
} elseif ($AssemblyPlant == "L" && ($ModelYear >= 59 && $ModelYear <= 63)){
echo "$AssemblyPlant = Linden, NJ<br />";
} elseif ($AssemblyPlant == "P" && ($ModelYear >= 59 && $ModelYear <= 63)){
echo "$AssemblyPlant = Pontiac, MI<br />";
} elseif ($AssemblyPlant == "S" && ($ModelYear >= 60 && $ModelYear <= 63)){
echo "$AssemblyPlant = Southgate, CA<br />";
} elseif ($AssemblyPlant == "T" && $ModelYear == "59"){
echo "$AssemblyPlant = Arlington, TX<br />";
} elseif ($AssemblyPlant == "W" && ($ModelYear >= 59 && $ModelYear <= 63)){
echo "$AssemblyPlant = Wilmington, DE<br />";
} else {
echo "Pontiac's weren't built at this plant in 19$ModelYear. Please check your VIN and try again.<br />";
}
$ProductionNumber=substr($decode,4,6);
if (is_Numeric($ProductionNumber)){
echo "$ProductionNumber = ";
echo $ProductionNumber - 1001;
echo "th Pontiac scheduled for production<br />";
} else {
echo "Invalid production number. Please check your VIN and try again.<br />";
}
// 1959 - 1963 Pontiac Ends
// 1964 Pontiac Begins
$ModelYear=substr($decode,2,1);
} elseif ($ModelYear == "4"){{
echo "";
}
$Engine=substr($decode,0,1);
if ($Engine == "6"){
echo "$Engine = 6-cylinder<br />";
} elseif ($Engine == "8"){
echo "$Engine = 8-cylinder<br />";
} else {
echo "Incorrect engine code. Please check your VIN and try again.<br />";
}
$Series=substr($decode,1,1);
if ($Series == "0"){
echo "$Series = Tempest<br />";
} elseif ($Series == "1"){
echo "$Series = Tempest Custom<br />";
} elseif ($Series == "2"){
echo "$Series = Lemans<br />";
} elseif ($Series == "3"){
echo "$Series = Catalina<br />";
} elseif ($Series == "6"){
echo "$Series = Star Chief<br />";
} elseif ($Series == "8"){
echo "$Series = Bonneville<br />";
} elseif ($Series == "9"){
echo "$Series = Grand Prix<br />";
} else {
echo "Pontiac didn't offer this series in 196$ModelYear. Please check your VIN and try again.<br />";
}
$ModelYear=substr($decode,2,1);
if ($ModelYear == "4"){
echo "$ModelYear = 196$ModelYear<br />";
} else {
echo "Incorrect model year. Please check your VIN and try again.<br />";
}
$AssemblyPlant=strtoupper(substr($decode,3,1));
if ($AssemblyPlant == "A"){
echo "$AssemblyPlant = Arlington, TX<br />";
} elseif ($AssemblyPlant == "D"){
echo "$AssemblyPlant = Doraville, GA<br />";
} elseif ($AssemblyPlant == "F"){
echo "$AssemblyPlant = Fremont, OH<br />";
} elseif ($AssemblyPlant == "K"){
echo "$AssemblyPlant = Kansas City, KS<br />";
} elseif ($AssemblyPlant == "L"){
echo "$AssemblyPlant = Linden, NJ<br />";
} elseif ($AssemblyPlant == "P"){
echo "$AssemblyPlant = Pontiac, MI<br />";
} elseif ($AssemblyPlant == "S"){
echo "$AssemblyPlant = Southgate, CA<br />";
} else {
echo "Pontiac's weren't built at this plant in 196$ModelYear. Please check your VIN and try again.<br />";
}
$ProductionNumber=substr($decode,4,6);
if (is_Numeric($ProductionNumber)){
echo "$ProductionNumber = ";
echo $ProductionNumber - 1001;
echo "th Pontiac scheduled for production<br />";
} else {
echo "Invalid production number. Please check your VIN and try again.<br />";
}
}
// 1964 Pontiac Ends
?>
Thanks for the help,
Arthur