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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.