Link to home
Start Free TrialLog in
Avatar of webappnewbie
webappnewbie

asked on

Form Returning empty variables

I've created a form which allows users to search faculty profiles by departments or schools.  The page reloads when the user selects Department or Schools radio buttons and values are populated in a dropdown depending on which category is selected. The problem I am having is that when the form is submitted, no value is returned for the selected school or department.

My codes is below:

<?php

$category = $_POST['category'];
$schoolsel = $_POST['schoolsel'];
$search_categories = $_POST['search_categories'];
$submit_cat = $_POST['submit_cat'];
$deptsearch = $_POST['department'];

                  If($category=='dept'){
                  $deptselect="SELECT * FROM Department";
                  $deptquery = odbc_do($dbconnect, $deptselect);
                  echo "<select id='department' name='department' >";
                  echo "<option>Select Department</option>";                   
                  while($deptshow = odbc_fetch_array($deptquery))
                  {
                  $showdept = $deptshow['dname'];
                  $showdeptid = $deptshow['did'];
                  echo "<option id='depts' name='depts' value=".$showdeptid.">".$showdept."</option>";
                  
                  } echo "</select>";}
                  
                  elseif ($category=='schools'){
                  $schoolsel = $_POST['schoolsel'];
                  $schoolselect="SELECT * FROM Schools";
                  $schoolquery = odbc_do($dbconnect, $schoolselect);
                  
                  echo "<select id='schoolsel' name='schoolsel'>";
                  
                  echo "<option value=''>Select School</option>";
                  while($schoolshow = odbc_fetch_array($schoolquery))
                  {
                  $showschool = $schoolshow['sname'];
                  $showschoolid = $schoolshow['sid'];
                  
                  echo "<option id='schoolop' name='schoolop' value=".$showschoolid." >".$showschool."</option>";
            
                  } echo "</select>"; };
      
                  ?>


<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" name="categories">
                  <input type="hidden" name="search_categories"  value="yes" >
                  <tr><td colspan="1" ><input type="radio" id="profiles" name="category" value="profiles"  checked maxlength="40"   >List All Profiles</td>
                  <td colspan="3"      align="right">
                  </td>
                  <tr><td colspan="1"><input type="radio" id= "dept"  name="category" value= "dept"  maxlength="40"  onClick="javascript:this.form.submit();" >Academic Departments</td><td>
                  
                  </td>
                  </tr>
                  <tr><td><input type="radio" id="schools" name="category" value="schools" maxlength="40"  checked onClick="javascript:this.form.submit();"   >Colleges/Schools</td></tr>
                  
                  <tr><td></td></tr>
                  <tr><td colspan="7" align="center"><input type="submit" name="submit_cat"  value="Select" checked></td></tr>
                  <tr><td></td></tr>
                  <tr><td></td></tr>
                  </form>
ASKER CERTIFIED SOLUTION
Avatar of gplana
gplana
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of webappnewbie
webappnewbie

ASKER

Newbie here :)

That did it!!! Thank you!
You are welcome !
Thank you for your rating.