my $_POST variables are going blank

Status
Not open for further replies.
A

Ardenn

anyone know why?

PHP:
<?

//Database Variables

$hostname = "localhost";
$username = "root";
$password = "";

//Connecting to Database

MYSQL_CONNECT($hostname, $username, $password) or die ("DB connection unavailable");
MYSQL_SELECT_DB ('phone_dir') or die ("Unable to select to database");

//DECLARING GLOBALS
GLOBAL $grab,$sort;


//declaring other variable
$i=0;
$metode=$_POST['metode'];
$search=$_POST['search'];


//declaring a function to query the database
function displayresults($ordered)

  {
    Global $i,$metode,$search;
    
    //These variables are echoed for troubleshooting purposes
    echo $metode;
    echo '<Br>';
    echo $search;
    echo '<br>';
    echo $ordered;
    echo '<br>';
    
    //Display the top of results table
    ECHO '

            <table>
              <tr>
                <td width="100" bgcolor="#999999"><div align="center"><b><u><a href="[url]http://127.1.1.1/test.php?sort=1">Lastname</u></b></div></td>[/url]
                <td width="100" bgcolor="#999999"><div align="center"><b><u><a href="[url]http://127.1.1.1/test.php?sort=2">Firstname</u></b></div></td>[/url]
                <td width="81" bgcolor="#CCCCCC"><div align="center"><b><u><a href="[url]http://127.1.1.1/test.php?sort=3">Extension</u></b></div></td>[/url]
                <td width="141" bgcolor="#999999"><div align="center"><strong><u><a href="[url]http://127.1.1.1/test.php?sort=4">Site</u></strong></div></td>[/url]
                <td width="143" bgcolor="#999999"><div align="center"><strong><u><a href="[url]http://127.1.1.1/test.php?sort=5">Admin[/url] #</u></strong></div></td>
              </tr>
            </table>';

    //SQL QUERY WHERE $metode = $_POST['metode'] and $search = $_POST['search'] and $ordered = the displayresults function argument.
    $result = mysql_query("SELECT * FROM all_swr WHERE $metode LIKE '%$search%' ORDER BY $ordered ASC") or die ('QUERY FAILED');
    
    //While Loop to list all matching resuts
    while ($row = mysql_fetch_array($result))
                {
                  //ALTERNATE ROW COLOR
                  IF ($i % 2 == 0)
                    {
                    $bgcolor = "#CCFFCC";
                    }
                  ELSE
                    {
                    $bgcolor = "#DDDDDD";
                    }

                  //table listing results
                  echo '
                  <table>
                    <tr bgcolor='.$bgcolor.'>
                      <td width="100">'.$row["Lastname"].'</td>
                      <td width="100">'.$row["Firstname"].'</td>
                      <td width="81"><B>'.$row["Extension"].'</b></td>
                      <td width="141">'.$row["Site"].'</td>
                      <td width="143">'.$row["ADM_LDN"].'</td>
                    </tr>
                  </table>';
                  $i++;
                }
  }
  
//Display the form
    ECHO '
            <table width="95%" border="0" cellspacing="0" cellpadding="4" bgcolor="#CCCCCC">
                <tr>
                  <td height="16" bgcolor="#0099CC"><font size="3"><b>Southwest Division Phone Directory Search</b></font></td>
                </tr>
              </table>

              <br>

              <center>

              <table width="300" height="67" border="4" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="290" bordercolor="#000000"><p align="center">
                    <form method="post" action="[url]http://127.1.1.1/test.php?grab=1">[/url]
                    <select name="metode" size="1">
                      <option value="FirstName">First Name</option>
                      <option value="LastName" selected>Last Name</option>
                      <option value="Extension">Extension</option>
                    </select>

                    <input type="text" name="search" size="25">
                    <br>
                    Search database: <input type="submit" value="Go!!" name="Go"></form>
                  </td>
                </tr>
              </table>';

//Processing the main form and sorts
IF ($grab==1)
    {
    displayresults("Site");
    }
ELSEIF ($sort==1)
    {
    displayresults("Lastname");
    }
ELSEIF ($sort==2)
    {
    displayresults("Firstname");
    }
ELSEIF ($sort==3)
    {
    displayresults("Extension");
    }
ELSEIF ($sort==4)
    {
    displayresults("Site");
    }
ELSEIF ($sort==5)
    {
    displayresults("Admin");
    }
ELSE
    {
    //display some cosmetic stuff
    echo'<p align="right"><img src="phone-handset.jpg" width="199" height="225" align="right"></p>
      <P align="left"><A name=and><B><FONT face="Arial, sans-serif" color=#003399>Searches</FONT></B></A>
      <P align="left" class=indent><span class="style3"><FONT size=-1>The SWR search engine </FONT><FONT size=-1> ignores common words and characters such as "where" and "how" as they tend not to be real people-like names. If you do not provide sufficient search criteria, your search may yield too much information so please, keep it simple and spell it right. </FONT></span></P>
      <P align="left"><A name=and><B><FONT face="Arial, sans-serif" color=#003399>Other </FONT></B><FONT face="Arial, sans-serif" color=#003399>Advanced <B>Search Features</B></FONT></A> </P>
      <div align="left">

      <LI><FONT size=-1><B>First Name :</B> Specify the FIRST name of the person for which you are searching. </FONT>
      <LI><FONT size=-1><B>Last Name: </B> Specify the LAST name of the person for which you are searching. </FONT>
      <LI><FONT size=-1><B>Extension: </B>You can reverse search on extension to return the associate user of the extension.</FONT>';
    }
?>
 
A

Ardenn

Everything is in the script above.  If you read the script, look for the comment //displays the form and you will see what I mean.
 
Status
Not open for further replies.
Top