Jump to content

unable to vaidate select field


$php_mysql$

Recommended Posts

hey guys im with no issue being able to validate the input field but select part i get error

 

my coding

 

$name=$_POST["name"]; 
$cat=$_POST["listing"];  //this is the select line
$state=$_POST["state"]; //this is the select line
$type=$_POST["type"]; 


if(empty($name) || empty($ad) || empty($location)) {
echo "<h3 align=\"center\">Error!</h3>\n";
echo "All fields are must<br/>";
die ("<h3 align=\"center\"><a href=\"index.php?action=main\">Home</a></h3>\n"); 
}

here is my html

echo "Choose Category:"; 
echo "<br/><select name=\"listing\">"; 
echo "<option value=\"\">Select Category</option>"; 
echo "<option value=\"career_jobs\">Career/Jobs</option>"; 
echo "</select><br/>"; 

echo "Choose state:"; 
echo "<br/><select name=\"state\">"; 
echo "<option value=\"\">Select state</option>"; 
echo "<option value=\"texas\">texas</option>"; 
echo "</select><br/>"; 


 

whenever i add the empty($listing) ||  my data is not entered into database and i get the all fields are must message

Link to comment
https://forums.phpfreaks.com/topic/240823-unable-to-vaidate-select-field/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.