We help IT Professionals succeed at work.
Get Started

Form Returning empty variables

webappnewbie
webappnewbie asked
on
404 Views
Last Modified: 2012-05-10
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>
Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE