I have a form that the data is submitted to PHP for processing. The form consists of 2 form fields that require a numeric value. Field 1 is Number of employees in let’s say Ohio, and the second is Number of employees nationwide. When the form is submitted and the data processed, it determines the correct program for the client based off of their answers and sends them to a page with program details.
The form data submits and is processed, but I am having these problems. In most cases the first form field will contain data and the second will be empty, or sometimes vice versa. If any field is empty, or if it contains a 0 it processes but the data in the field containing data is ignored and the user is sent to the first if statement URL.
The last elseif statement, no matter what number is entered, it is processed by the first if statement. It has been a long time since I written even a small PHP script, and I am probably missing something simple, but I don’t see it.
<?php
$product1 = $_REQUEST['product1'] && $product2 = $_REQUEST['product2'];
if (($product1 <= 50) && ($product2 <= 50))
{echo "<script type='text/javascript'>location.href='http://yahoo.com/'</script>";}
elseif (($product1 >= 51 && $product1 <=100) && ($product2 >= 51 && $product2 <=100))
{echo "<script type='text/javascript'>location.href='http://msn.com/'</script>";}
elseif (($product1 >= 101 && $product1 <= 200) && ($product2 >= 101 && $product2 <= 200))
{echo "<script type='text/javascript'>location.href='http://google.com/'</script>";}
elseif (($product1 >= 201 && $product1 <= 249) && ($product2 >= 201 && $product2 <= 249))
{echo "<script type='text/javascript'>location.href='http://aol.com/'</script>";}
elseif (($product1 > 250) && ($product2 > 250))
{echo "<script type='text/javascript'>location.href='http://tigerdirect.com/'</script>";}
?>
The form being submitted
<form id="form1" name="form1" method="post" action="http://xxxxttt.com/Untitled-1.php">
<label>Product 1</label><input type="text" name="product1" id="product1" />
<label>Product 2</label><input type="text" name="product2" id="product2" />
<input type="submit" name="submit" id="submit" value="submit" />
</form>