timmah1 Posted December 19, 2008 Share Posted December 19, 2008 Hopefully last time today I have a form where users can input items If a text area is empty, it still inputs the name of the field into the database. How can I make it so that if there is 4 items on the page, and only 1 is filled out, the only thing that gets entered is the field with something in it? Does that make sense? Here is what I have now that enters everything regardless if something was entered or not while (list ($name,$val) = @each ($_POST['pick_'])) { //while (list ($name,$val) = @each (mysql_real_escape_string($_POST['pick_']))) { $sport = $_POST['sport']; $active = $_POST['yr']."-".$_POST['month']."-".$_POST['day']; $spl_date = $_POST['yr_spl']."-".$_POST['month_spl']."-".$_POST['day_spl']; $val = stripslashes($val); $val = mysql_real_escape_string($val); $sql = "INSERT INTO dailypicks1(sport, package, picks, active, month_spl) VALUES( '$sport', '$name', '$val', '$active', '$spl_date');"; mysql_query($sql) or die("Sorry, there was a problem creating your account ".mysql_error()); } Meaning, if $name's $va is nothing, name or value doesn't go into the database, but the rest of the form does. Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/137721-solved-empty-post-dont-enter/ 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.