Jump to content

[SOLVED] Empty post, don't enter


timmah1

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/137721-solved-empty-post-dont-enter/
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.