Page 1 of 1

passing variables from input form to php page

Posted: Thu Jul 24, 2008 12:51 pm
by okelly
hi

the input form below passes "category" selection to a listings.php page. The "Category" variable doesn't seem to be passing from the input form to the $cat = $_POST['category'] on the listings.php (code below)page.
Any ideas?

Code: Select all

 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
 <body>
<form name="listing.php" method="post">
<table border="1">
<tr>
<td> category</td>
<td> <select name= "category">
<option value=" " selected> Select Category</option>
<option value="Voluntary Filing">Voluntary Filing</option>
<option value="Mandatory Filing">Mandatory Filing</option>
<option value="Development">Development</option>
</select>
<input type="submit" name="submit" value="search">
</td>
</tr>
</table>
</form>
</body>
</html>
 
here is the listing.php

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php include ('../admin/config.php'); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
             <?php       
        $cat = $_POST['category'] ;
        $result = mysql_query("SELECT projects.id, projects.name, projects.cat FROM projects WHERE cat='$cat' ",$dblink);
        echo "<table border=\"0\">\n" ;
        while ($row = mysql_fetch_assoc($result)){
        echo "<tr>\n" ;
        foreach($row as $value) {
        echo "<td>\n" ;
             echo $value;
        echo "</td>\n" ;
             }
        echo "</tr>\n" ;     
             }
        echo "</table>\n" ;
   ?>       
</body>
</html>
 

Re: passing variables from input form to php page

Posted: Thu Jul 24, 2008 2:04 pm
by okelly
oops...just noticed <form name="listing.php" method="post"> should have read <form ACTION="listing.php" method="post">

darn... knew it was something stupid!