I am trying to write a check for Vendors and models in a form I have put together
Here is the relavent part of the form
<table width="75%">
<form action="?" method="post">
<tr>
<td colspan="6" align="center">
<font size="5"><b>Add new record</b></font>
</td>
</tr>
<tr>
<td align="right">
<b>Vendor:</b>
</td>
<td>
<select name="vendor">
<option value="ClearAccess">ClearAccess</option>
<option value="VisionNet">VisionNet</option>
<option value="Other">Other</option>
</select>
</td>
<td align="right">
<b>Model:</b>
</td>
<td>
<select name="model">
<option value="NotModel">--ClearAccess--</option>
<option value="AG10W">AG10W</option>
<option value="SR100G">SR100G</option>
<option value="SR300N">SR300N</option>
<option value="SR350N">SR350N</option>
<option value="SR500N">SR500N</option>
<option value="NotModel">--VisionNet--</option>
<option value="M404">M404</option>
<option value="M405">M405</option>
<option value="M505">M505</option>
<option value="M505n">M505N</option>
<option value="Legacy">Legacy</option>
</select>
</td>
my form is good. my issue is when I am building my if loop. Here is what I have so far
if ($_POST['vendor']='ClearAccess') && ($_POST['model']='M404') || ($_POST['model']='M405') || ($_POST['model']='M505') || (_$POST['model']='M505N') || ($_POST['model']='Legacy')
echo "You have not selected a valid vendor/model combination"
I am having an issue with where and how to place my parenthesis.
I am also going to create an if statement similar to this
if ($_POST['vendor']='VisionNet') && ($_POST['model']='AG10W') || ($_POST['model']='SR100G') || ($_POST['model']='SR300N') || (_$POST['model']='SR350N') || ($_POST['model']='SR500N')|| ($_POST['model']='Legacy')
echo "You have not selected a valid vendor/model combination"
I am completely open to doing it different ways. Eventually I will turn this into java script where you pick a vendor and get only the relavant models for that vendor. Put as I am still learning PHP and have not learned even the basics of Java yet I want to try it this way.
You must use
==
instead=
in your if conditions.So instead of:
use
Better to have your if condition like this: