$php_mysql$ Posted June 30, 2011 Share Posted June 30, 2011 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 Quote Link to comment Share on other sites More sharing options...
Maq Posted June 30, 2011 Share Posted June 30, 2011 What's the error? Quote Link to comment Share on other sites More sharing options...
$php_mysql$ Posted June 30, 2011 Author Share Posted June 30, 2011 error message is my own error message this echo "All fields are must<br/>"; shows when i try to validate the select drop down filed Quote Link to comment Share on other sites More sharing options...
$php_mysql$ Posted June 30, 2011 Author Share Posted June 30, 2011 say by default it shows like this echo "<option value=\"\">Select state</option>"; so if a user do not select the state value is empty when i try to validate it by adding empty($state) i get error Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 30, 2011 Share Posted June 30, 2011 $ad and $location don't exist, to this: empty($ad) || empty($location) will throw the error Quote Link to comment Share on other sites More sharing options...
$php_mysql$ Posted June 30, 2011 Author Share Posted June 30, 2011 oh yes i missed that thanks, well i added them but still the i get error when i try to validate the drop down fields Quote Link to comment Share on other sites More sharing options...
$php_mysql$ Posted June 30, 2011 Author Share Posted June 30, 2011 oops nevermind fixed :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.